• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 158
  • Last Modified:

Displaying the time on unix using C

I've been using localtime() to display the time on a Sun Workstation (Solaris 5.X) but I don't get the right time. The time that I get on the tm structure is 11/31/69. Note that I use the clock() function to retrieve the time_t structure needed by localtime(). So it my be the clock() function that is not working.
0
doscar
Asked:
doscar
1 Solution
 
ozoCommented:
#include <time.h>

 time_t t;
 t = time(NULL);
 printf("%s",asctime(localtime(&t)));
0
 
sgantaCommented:
you can display using
system(date);
0
 
doscarAuthor Commented:
Hey guys, The answer that I was looking for was given by ozo. So I was wandering how would I be able to grade his answer. Now, if ozo doesn't mind I'm willing to grade sganta answer.

 
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now