• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 159
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get Certified for a Job in Cybersecurity

Want an exciting career in an emerging field? Earn your MS in Cybersecurity and get certified in ethical hacking or computer forensic investigation. WGU’s MSCSIA degree program was designed to meet the most recent U.S. Department of Homeland Security (DHS) and NSA guidelines.  

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