SUMMARY: convert seconds to date

From: Cynthia Shang x7484 (shang@mailhost.la.AirTouch.COM)
Date: Wed Aug 14 1996 - 15:30:18 CDT


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

                                        Cynthia Shang
                                        AirTouch Cellular
                                        shang@la.airtouch.com

Many thanks to the following individuals for their quick
responses:

Jochen Fritz <jfritz@steptools.com>
Edward Grimm <edgrimm@neptune.mtc.ti.com>
Wis Macomson <wis@sequent.com>
Tim Pointing <tim@ben.dciem.dnd.ca>
jonesmd@unifiedtech.com (Mike Jones)
kpischke@cadence.com (Karlheinz Pischke)
Laurent Duperval <laurent@Grafnetix.COM>
poffen@San-Jose.ate.slb.com (Russ Poffenberger)
mike@trdlnk.com (Michael Sullivan)
"Mark B. Hamby" <mhamby@logicon.com>
Henry Katz <hkatz@panix.com>
rh1559@s4690.williams-int.com (Rod L. Henry)



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:11:08 CDT