Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting system Time

Status
Not open for further replies.

moonoo

Programmer
May 17, 2000
62
US
Hi
How to get the System time without using the MFC classess
CTime and CString..
I want the date and time in the YYYY/MM/DD HH:MM:SS format
and i am using the follwing code

time_t ltime ;
char tmpbuf[128] ;
struct tm *today;
today = localtime( &ltime );
strftime(tmpbuf,25,"%Y/%m/%d %H:%M:%S",today);

This funcyion is giving the Date 1970/01/01 09:00:00 in stead of the current time and date..
Is there some others structures and functions available by which i can get the current date and time by the above method(without using the MFC Classes)

Please give an early reply..
Dev
 
you have to do this i believe:

ltime = time(NULL);

befor useing localtime()
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top