My original question:
Is there a command, program, or script that can convert the
number of seconds since 1/1/1970 to the "date" format?
Ex: 788400532 => Sun Dec 25 16:08:52 1994
There are a couple of C library functions such as 'ctime'
and 'localtime', according to the MAN page, that are
supposed to do exactly what I need. However, when I
wrote a C program to test them out, the answers weren't
accurate. For example, if I supply "3600" as input, I
should get an output of "Thu Jan 1 01:00:00 1970" but
instead I got "Wed Dec 31 17:00:00 1969". Any clue?
By the way, I am in US-Pacific time zone.
Many people pointed out that the input to ctime is in GMT,
and the answer it gives back is based on my local time zone
(US-PACIFIC), which is 8 hours ahead of GMT.
To get the consistent answer for my timezone, I can either
add 28800 (8 hrs worth of seconds) to the input or set my
timezone to GMT prior to running of my program with
"setenv TZ GMT".
A few people gave me pointers to Perl scripts and C programs
that can help perform the conversion. Tim Pointing showed me
a simple alias that will do the job:
% alias todate '(setenv TZ GMT;echo 0t\!*=Y|adb)'
% todate 3600
1970 Jan 1 01:00:00
Many thanks to the following individuals for their quick
Jochen Fritz <email@example.com>
Edward Grimm <firstname.lastname@example.org>
Wis Macomson <email@example.com>
Tim Pointing <firstname.lastname@example.org>
email@example.com (Mike Jones)
firstname.lastname@example.org (Karlheinz Pischke)
Laurent Duperval <laurent@Grafnetix.COM>
poffen@San-Jose.ate.slb.com (Russ Poffenberger)
email@example.com (Michael Sullivan)
"Mark B. Hamby" <firstname.lastname@example.org>
Henry Katz <email@example.com>
firstname.lastname@example.org (Rod L. Henry)
This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:11:08 CDT