Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: Boyd Adamson <boyd-adamson@usa.net>
To: Pedro Nobre <pmn@edinet.pt>
Subject: Re: timestamp (unix time)
Date: 1998/12/03	[thread overview]
Message-ID: <3665F0A9.E7A286CC@usa.net> (raw)
In-Reply-To: 743p02$8ps1@globo.edinfor.pt

Pedro Nobre wrote:
> 
> Thanks, but that isn�t realy what i�m looking for.
> You are write, i'm making a shell script, but let me explain it better:
> Unix stores date in a long integer that represents the number of seconds
> since Jan,1,1970.
> What i pretend is something that decodes a number, say "912614795", to a
> date "02-12-1998 16:05:31" corresponding to that number.
> 
> Pedro
Sounds like what you need is a program called unixSex, written by one of
my colleagues. It will convert from time_t values (seconds from the
epoch) to and from a date string, allowing you to specify a format
string so the date can be in whatever format you want.

Since you don't have a compiler, I can mail you an executable if you
like.

For example:

titan:~$ unixSex -h
Usage:
   To print seconds since the Epoch (01/01/1970) to stdout:
      unixSex
   To print seconds since the Epoch for a date string to stdout (default
   fmt-string: "%Y%m%d%H%M%S"; use %b, %B, %d, %H, %m, %M, %S, %y or
%Y):
      unixSex "[date-str]" "[fmt-string]"
   The reverse: print time string (like output from 'date') to stdout:
      unixSex -v [seconds-since-Epoch]
   Same as the previous, allowing user-defined format (see 'man
strftime'):
      unixSex -v [seconds-since-Epoch] "[fmt-string]"
titan:~$ unixSex
912646323
titan:~$ unixSex -v 912646323
Thu Dec 03 10:52:03 AEST 1998

Or, more specifically to your question:

titan:~$ unixSex -v 912614795 "%d-%m-%Y %H:%M:%S"
03-12-1998 02:06:35
titan:~$ 

Heh... I guess we're in different timezones.

titan:~$ TZ=:GMT unixSex -v 912614795 "%d-%m-%Y %H:%M:%S"
02-12-1998 16:06:35
titan:~$

Boyd
--



  reply	other threads:[~1998-12-03  5:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-12-02  5:00 timestamp (unix time) Pedro Nobre
1998-12-02  5:00 ` Ed Wensell III aka THE StormRaiser
1998-12-02  5:00   ` Pedro Nobre
1998-12-03  5:00     ` Boyd Adamson [this message]
1998-12-03  5:00     ` Jeffrey Mogul
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox