Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!samsung!think.com!paperboy!hsdndev!frooz!cfa.HARVARD.EDU From: murison@cfa.HARVARD.EDU (Marc A. Murison, RG) Newsgroups: comp.lang.c Subject: Re: Time Message-ID: <510@cfa.HARVARD.EDU> Date: 7 Feb 91 14:24:17 GMT References: <8258@castle.ed.ac.uk> Sender: news@cfa.HARVARD.EDU Distribution: comp Lines: 24 From article <8258@castle.ed.ac.uk>, by james@castle.ed.ac.uk (J Gillespie): > > Is there a simple way of getting hold of the system time from within a > C program? Here's how I do it: #include #include void main( void ) { time_t cur_time; /* get the current date and time */ time(&cur_time); /* ctime() converts a value of type time_t to a string */ printf( "\ncurrent time = %s", ctime(&cur_time) ); } Marc Murison Smithsonian Astrophysical Observatory murison@cfacx2.harvard.edu (the address in the header will bomb)