arichexe
asked on
today's date minus 7 days
How would I write a C function that returns today's date minus 7 days? For instance, if today's date was 11/13/2006, it would return 11/6/2006.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
time() would give you current time in seconds since epoch ...
Subtract 7 * 24 * 3600 from this value ... this would give you time 7 days ago ...
To get other representations of this time, use ctime/ctime_r etc
time_t val = time (NULL);
val = val - (7 * 24 * 3600);
printf ("%s",ctime(&val));
Cheers!
sunnycoder