[sf-lug] unix time conversion

Alex Kleider a_kleider at yahoo.com
Mon Oct 27 15:46:04 PDT 2008


--- On Mon, 10/27/08, Charles-Henri Gros <chgros at coverity.com> wrote:

> Alex Kleider wrote:
> > --- On Mon, 10/27/08, Asheesh Laroia
> <asheesh at asheesh.org> wrote:
> >> Note that 1969 (well, 1970, but 1969 in US
> timezones) and
> >> 2038 are 
> >> respectively the beginning and the end of time_t 
> >> <http://en.wikipedia.org/wiki/Unix_time>.
> >>
> >> -- Asheesh.
> >>
> > 
> > I followed up on your wiki reference and would like to
> know how to 
> > convert Unix time -893,400,000 into a date I can
> understand.
> > date -d'-893400000'
> > doesn't work on my system.
> > 
> > perl -e “require ‘ctime.pl’; print
> &ctime($EPOCH);”
> > was suggested in one of the links but I've no idea
> where to stick the negative number.
> 
> Replace $EPOCH with it
> 
> > perl -e "require 'ctime.pl'; print
> &ctime(-893400000);"
> Tue Sep  9  9:20:00 1941
> 
> > can python do this for us?
> 
> Certainly
> 
> > echo 'import time; print
> time.ctime(-893400000);' | python
> Tue Sep  9 09:20:00 1941
> 
Got it!

Now that you have wetted my appetite:
How to change a human readable time into 'unix time?'
(preferably using python so this becomes applicable to the ThinkPython grp)

>>> string = "July 3, 1945"
>>> import time
>>> time(string)

the above doesn't work but is it just because the format of the date is incorrect or is there a bigger problem?



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 




More information about the sf-lug mailing list