Does anybody know C/C++ function to obtain system date and time by not using MFC? (which allow achieve same result as CTime::GetCurrentTime())
Printable View
Does anybody know C/C++ function to obtain system date and time by not using MFC? (which allow achieve same result as CTime::GetCurrentTime())
This should do what you need
#include <time.h>
{
time_t t;
t = time(NULL);
tm *timeinfo;
timeinfo = gmtime(&t);
//timeinfo.tm_sec; /*int seconds after the minute - [0,59] */
//timeinfo.tm_min; /*int minutes after the hour - [0,59] */
//timeinfo.tm_hour; /*int hours since midnight - [0,23] */
//timeinfo.tm_mday; /*int day of the month - [1,31] */
//timeinfo.tm_mon; /*int months since January - [0,11] */
//timeinfo.tm_year; /*int years since 1900 */
//timeinfo.tm_wday; /*int days since Sunday - [0,6] */
//timeinfo.tm_yday; /*int days since January 1 - [0,365] */
//timeinfo.tm_isdst; /*int daylight savings time flag */
}
HTH,
Chris
If you are in windows You can use ::GetSystemTime()
Ramanan