CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

How to convert UTC timestamp into time string

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
HHoward



Joined: 29 Aug 2006
Posts: 9
Location: Silicon Valley, CA

View user's profile Send private message

How to convert UTC timestamp into time string
PostPosted: Wed Sep 13, 2006 6:32 pm     Reply with quote

Question How to convert UTC timestamp into time string such as yyyymmhhmmss?
Mattr0



Joined: 27 Mar 2005
Posts: 30

View user's profile Send private message Visit poster's website

PostPosted: Wed Sep 13, 2006 7:09 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Sep 13, 2006 8:03 pm     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group