get time -> day/mo/year etc
I was trying to write some code that converted the thing returned by timeGetTime() into the format "of dd/mm/yy hh:mm:ss",
but then I found out that timeGetTime wraps around every 50 days or something, and is not what I wanted at all.
What is the function in c++ that returns the number of milliseconds since jan1, 1970? I think I can easily get the current date out of that.
Or is there an even easier way to determine the current day in c++?
The time function:
quote:
time, _time64
Get the system time.
time_t time(
time_t *timer
);
__time64_t _time64(
__time64_t *timer
);
Parameters
timer
Pointer to the storage location for time.
Return Value
Return the time in elapsed seconds. There is no error return.
A call to time or _time64 can fail, however, if the date passed to the function is:
Before midnight, January 1, 1970.
After 19:14:07, January 18, 2038, UTC (using time and time_t).
After 23:59:59, December 31, 3000, UTC (using _time64 and __time64_t).
call the time function to get the number of seconds since 1970..
then call localtime to get a tm structure. from here you can use printf to format it however you want.
"Absorb what is useful, reject what is useless, and add what is specifically your own." - Lee Jun Fan
then call localtime to get a tm structure. from here you can use printf to format it however you want.
"Absorb what is useful, reject what is useless, and add what is specifically your own." - Lee Jun Fan
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement