Archived

This topic is now archived and is closed to further replies.

current Time ?

This topic is 5745 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts


    
#include <stdio.h>
#include <time.h>

int main()
{
time_t ttime;
tm* pCurTime;
char cTimeString[32];

//Get the current time

time(&ttime);
pCurTime = localtime(&ttime);
strftime(cTimeString, 32, "%m/%d/%Y at %H:%M:%S",pCurTime);

printf("The date and time are: %s", cTimeString);
return 0;
}


This outputs a time in the format "03/23/2002 at 12:31:44"

voila the current time and date. To learn more about the formatting of the string, look up strftime().

--------------------------

Those who dance are considered insane by those who cannot hear the music.

[edited by - terminate on March 23, 2002 4:59:03 PM]

Share this post


Link to post
Share on other sites