I tried strftime( ) to get a formatted time-stamp.
char ft[ 256 ]; struct tm *tmp; strftime( ft, 256, '%D - %T', tmp );
My problem is that I get ’13/02/60 – 03:07:-17958194′ as a result. Is there a way to display the seconds properly? (I’m using Mac OS X and gcc)
You’re using an uninitialized value in the code that you’ve posted, which would explain why you have this problem. The following code results in what you’re looking for:
Then, compile and run the example:
ETA: Drop the %s if you just want the local time without UNIX time after it, of course.