Link to home
Start Free TrialLog in
Avatar of Karls
Karls

asked on

using date functions

I need to put system date details in either 1 or 3 variables
ie
date_today = yymmdd

or

date_year = yy
date_month = mm
date_day = dd

thanks
Avatar of mnashadka
mnashadka

You can use time(NULL) to get a time_t, then localtime to get a struct tm representing the time:
time_t now = time(NULL);
struct tm *time_data = localtime(&now);

Then you can use the tm_mon (the month starts at 0, so you'll probably add 1), tm_year, and tm_mday struct elements to get the data that you need.
Avatar of Axter
Use the strftime function
ASKER CERTIFIED SOLUTION
Avatar of Axter
Axter
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial