Re: HowTo convert "seconds since `00:00:00 1970-01-01 UTC" into a human readable date
From: Web Surfer (raisin_at_delete-this-trash.mts.net)
Date: 04/18/04
- Next message: Michael Heiming: "Re: How to become a System Administrator?"
- Previous message: Dave Dickerson: "Re: Print screen??"
- In reply to: Hermann Peifer: "HowTo convert "seconds since `00:00:00 1970-01-01 UTC" into a human readable date"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 18 Apr 2004 09:46:11 -0500
[This followup was posted to comp.unix.questions]
11.news.tele.dk>, peifer@gmx.net says...
> Hi All,
>
> Here my small problem:
>
> I have a list with timestamps expressed as
> "seconds since `00:00:00 1970-01-01 UTC", see here:
>
> 1081784344
> 1081784346
> 1081784347
> 1081784545
> 1081784546
> 1081784658
> ...
>
> I would like to convert them into human readable dates, e.g.
>
> 2004-04-13 20:06:37
>
> IMHO, the solution seems to be around strftime() or strptime() functions,
> but I don't manage to get it right.
>
> Any solution is welcome, preferably a simple one, e.g. a shell oneliner.
>
> Regards, Hermann
>
Here is the source code for a very small C program that can do the job :
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
time_t clock;
clock = (time_t)atoi(argv[1]);
printf("%s",ctime(&clock));
exit(0);
}
- Next message: Michael Heiming: "Re: How to become a System Administrator?"
- Previous message: Dave Dickerson: "Re: Print screen??"
- In reply to: Hermann Peifer: "HowTo convert "seconds since `00:00:00 1970-01-01 UTC" into a human readable date"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]