![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| date manipulation | pstanand | Shell Programming and Scripting | 6 | 04-03-2008 07:11 AM |
| need help in time manipulation | ali560045 | Shell Programming and Scripting | 6 | 03-11-2008 07:41 AM |
| Manipulation of Date in Shell | jnanesh.b | Shell Programming and Scripting | 1 | 01-11-2008 10:16 AM |
| Date Manipulation | mgirinath | Shell Programming and Scripting | 6 | 04-03-2007 01:25 AM |
| date manipulation | jalburger | Shell Programming and Scripting | 3 | 05-10-2004 10:09 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Time/date manipulation
hey folks,
been awhile (actaully a long while) since i last touched C. And the 3 books i've read don't really have much about using time.h Question: How would i be able to assign a variable the value of the current date minus 2 mths, keeping in mind the yr. IE. would like to see Nov.31/2001 not Nov.31/2002. sounds simple enough, but i'm remembering that there's nothing "easy" with C. thanks, choice |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Code:
struct timeval tv;
struct timezone tz;
struct tm *tm;
gettimeofday(&tv, &tz);
tm=localtime(&tv.tv_sec);
for(n=0; n<2; n++)
if(!tm->tm_mon--)
tm->tm_mon=11,
tm->tm_year--;
fputs(asctime(tm), stdout);
|
||||
| Google The UNIX and Linux Forums |