View previous topic :: View next topic |
Author |
Message |
HHoward
Joined: 29 Aug 2006 Posts: 9 Location: Silicon Valley, CA
|
How to convert UTC timestamp into time string |
Posted: Wed Sep 13, 2006 6:32 pm |
|
|
How to convert UTC timestamp into time string such as yyyymmhhmmss? |
|
|
Mattr0
Joined: 27 Mar 2005 Posts: 30
|
|
Posted: Wed Sep 13, 2006 7:09 pm |
|
|
You need to provide more info for this. Are hours, Min, sec, etc... in seperate varibles?
if so it is easy
Code: |
char timestamp[13];
sprintf(timestamp,"%LU%02U%02U%02U%02U",years,month,hour,min,sec);
|
This will print all of this information into a string. Assumming year is a long and the rest are intergers. Lookup the sprintf function for more information
The %02 will print proceeding zeros up to 2 characters so the output will always be zero padded. otherwords you would get 200602120430 for febuary 2006 at 12:04:30. I notice there is no day in there but that is easy to add, just follow the format.
I hope that helps.
Matt |
|
|
HHoward
Joined: 29 Aug 2006 Posts: 9 Location: Silicon Valley, CA
|
|
Posted: Wed Sep 13, 2006 8:03 pm |
|
|
Only information I got is as followings:
UTC time sec in unsigned long
UTC time usec in unsigned long
I need some knowledge to know UTC second started from what time, 1/1/1970? How to use UTC usec to calculate leap second and compensate with data/time conversion?
Thanks. |
|
|
|