![]() |
|
|
|
|
|||||||
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| To convert multi format file to a readable ascii format | gaur.deepti | UNIX for Dummies Questions & Answers | 5 | 03-25-2008 11:03 AM |
| get the timestamp of a file in desired format | sumeet | UNIX for Advanced & Expert Users | 1 | 03-08-2007 08:24 AM |
| Select entries between two dates by converting Unix timestamp in Oracle Database. | amitsayshii | UNIX for Advanced & Expert Users | 1 | 08-08-2006 08:00 AM |
| human readable format of file size when doing ls –l | umen | UNIX for Dummies Questions & Answers | 1 | 09-28-2005 06:20 AM |
| Converting BMP to BM (or other unix format) | EJ =) | UNIX Desktop for Dummies Questions & Answers | 1 | 06-12-2002 05:42 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
converting unix timestamp into readable format using c++
hi everyone, im new here and am in desperate need of help. I want to convert my 32 bit unix time stamp ' 45d732f6' into a readable format (Sat, 17 February 2007 16:53:10 UTC) using c++.
I have looked around the interent but i just cant make sense of anything. All examples i can find just get the current date and time they dont actually show you how to take an actual timestamp and convert it. I really hope you guys can help me, im not a great programmer and would greatly appreciate an example or some guidence as to how to proceed thank you |
| Forum Sponsor | ||
|
|
|
|||
|
Since you did not provide feedback I tried to figure it out myself. The hex string is the seconds from the UNIX epoch and translates to Sat 17 February 2007 16:53:10 UTC
Code:
#include <stdio.h>
#include <time.h>
main(void)
{
time_t epch = 0x45d732f6;
printf("0x%x -> %s", epch, asctime(gmtime(&epch)));
}
|
| Thread Tools | |
| Display Modes | |
|
|