How to convert UNIX time stamp to syatem time stamp

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Nov 2008
Posts: 5
Reputation: spanigrahi_situ is an unknown quantity at this point 
Solved Threads: 0
spanigrahi_situ spanigrahi_situ is offline Offline
Newbie Poster

How to convert UNIX time stamp to syatem time stamp

 
0
  #1
Nov 26th, 2008
HI All,
Ant Unix method or C++ method is there to convert unix time stamp to system time stamp.The input is ULONG and out put should be in string.


u can intimate to <email snipped>
Any help is appreciated in advance.
Last edited by Ancient Dragon; Nov 26th, 2008 at 8:47 am. Reason: snipped email
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 2,001
Reputation: ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of 
Solved Threads: 343
ArkM's Avatar
ArkM ArkM is offline Offline
Postaholic

Re: How to convert UNIX time stamp to syatem time stamp

 
0
  #2
Nov 26th, 2008
Can you explain what is meant by "unix timestamp" and (mainly) "system timestamp"?
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 5
Reputation: spanigrahi_situ is an unknown quantity at this point 
Solved Threads: 0
spanigrahi_situ spanigrahi_situ is offline Offline
Newbie Poster

Re: How to convert UNIX time stamp to syatem time stamp

 
0
  #3
Nov 27th, 2008
Originally Posted by ArkM View Post
Can you explain what is meant by "unix timestamp" and (mainly) "system timestamp"?
unix time stamp is like = 1227806311
the same system time stamp is = 27/11/2008 HR MIN SEC
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 1,999
Reputation: ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of 
Solved Threads: 295
ddanbe's Avatar
ddanbe ddanbe is offline Offline
Posting Virtuoso

Re: How to convert UNIX time stamp to syatem time stamp

 
0
  #4
Nov 27th, 2008
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 2,001
Reputation: ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of 
Solved Threads: 343
ArkM's Avatar
ArkM ArkM is offline Offline
Postaholic

Re: How to convert UNIX time stamp to syatem time stamp

 
0
  #5
Nov 27th, 2008
I have never seen before so funny "definitions" of a "unix timestamp" data type and a "system time" representation:
unix time stamp is like = 1227806311
the same system time stamp is = 27/11/2008 HR MIN SEC
Well, try to adopt this code:
  1. /* UnixTime is unspecified unix time stamp type.
  2.   * Define it before compilation, for example:
  3.   * typedef time_t UnixTime;
  4.   * or
  5.   * typedef long int UnixTime;
  6.   */
  7. UnixTime ut; /* Unix timestamp to be converted */
  8.  
  9. time_t thist; /* This system timestamp value */
  10. struct tm* ptm;
  11. char mysyst[20] = "\?"; /* for "sys time" */
  12. const char* fmt = "%d/%m/%Y %H %M %S"; /* sys?time */
  13. /* C Standard does not specify what's time_t epoch */
  14. time_t uepoch; /* Unix epoch in this system time_t */
  15. struct tm tmepoch;
  16. /* Prepare unix time epoch on this system */
  17. memset(&tmepoch,0,sizeof tmepoch);
  18. tmepoch.tm_year = 1970 - 1900;
  19. tmepoch.tm_mon = 1 - 1;
  20. tmepoch.tm_mday = 1;
  21. tmepoch.tm_hour = 0;
  22. tmepoch.tm_min = 0;
  23. tmepoch.tm_sec = 0;
  24. uepoch = mktime(&tmepoch); /* this system unix epoch */
  25. /* Recalculate unix time to this system time_t */
  26. thist = (time_t)ut - uepoch;
  27. ptm = gmtime(&thist);
  28. if (ptm && strftime(mysyst,sizeof mysyst,fmt,ptm))
  29. printf("%s\n",mysyst);
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 5
Reputation: spanigrahi_situ is an unknown quantity at this point 
Solved Threads: 0
spanigrahi_situ spanigrahi_situ is offline Offline
Newbie Poster

Re: How to convert UNIX time stamp to syatem time stamp

 
0
  #6
Dec 11th, 2008
Sry to tell you guys my output time should be GMT or UTC.Any one plz help me on this urgently?
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 751
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: How to convert UNIX time stamp to syatem time stamp

 
0
  #7
Dec 11th, 2008
> Any one plz help me on this urgently?
You've had 13 days to play with the code ArkM posted, and now you're trying to make it into OUR problem?

http://www.catb.org/~esr/faqs/smart-...ns.html#urgent
Ha ha ha ha ha *plonk*
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 5
Reputation: spanigrahi_situ is an unknown quantity at this point 
Solved Threads: 0
spanigrahi_situ spanigrahi_situ is offline Offline
Newbie Poster

Re: How to convert UNIX time stamp to syatem time stamp

 
0
  #8
Dec 11th, 2008
hmmmm dude i was busy with some other issues.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 2,001
Reputation: ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of 
Solved Threads: 343
ArkM's Avatar
ArkM ArkM is offline Offline
Postaholic

Re: How to convert UNIX time stamp to syatem time stamp

 
0
  #9
Dec 11th, 2008
Originally Posted by spanigrahi_situ View Post
hmmmm dude i was busy with some other issues.
Just the TIME to go on with that issues ...
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 751
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: How to convert UNIX time stamp to syatem time stamp

 
0
  #10
Dec 11th, 2008
> hmmmm dude i was busy with some other issues.
Your choice - give up programming or give up something else.

You're not going to learn anything by dipping into programming for a couple of hours a month, so I'd say give up.

Otherwise you would have found a way to do something in the last fortnight, rather than just showing up here at the last minute hoping for salvation.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC