Click to See Complete Forum and Search --> : How to get system date&time by no using MFC (CTime, etc)?


Kondrat
May 27th, 1999, 08:30 AM
Does anybody know C/C++ function to obtain system date and time by not using MFC? (which allow achieve same result as CTime::GetCurrentTime())

ChrisD
May 27th, 1999, 09:46 AM
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

ramanan
May 27th, 1999, 10:10 AM
If you are in windows You can use ::GetSystemTime()

Ramanan