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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Time/Date problem on NT4

Status
Not open for further replies.

jamescpp

IS-IT--Management
Aug 29, 2001
70
US
I'm not much of a C programmer, but do some programming in other languages. I have a task of updating some code in a C program and having some trouble with using time and date information. The program is running on Windows NT 4 and I believe it's not returning any date at all because I end up with "Wed Dec 31 19:00:00 1969". Code snipet below. Can anyone help or make suggestions? Using Visual C++.

Thanks.
James (by the way, I end up doing more than just printing the time/date to the screen, that's just for debugging purposes)

struct tm *local;
time_t t;

local = localtime(&t);
printf(ctime(&t));

This yields:
Wed Dec 31 19:00:00 1969
 
You need to set t to something. For example to do the current time:

time_t t;

t = time(NULL); <---
printf(ctime(&t));

 
Yep, that did it. Thank you very, very much.

James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top