(RADIATOR) Timestamps

Jerome Fleury jeje at jeje.org
Mon Apr 1 06:24:17 CST 2002


--On dimanche 31 mars 2002 23:31 -0800 Steve Brown <steve at neteze.com> wrote:

> Well, if by unix timestamp you mean seconds past the epoch, just call
>
> 	date -r [timestamp]
>
> and the output will be a real date. You can adjust the format as necessary
> using plain old date formatting I believe. YMMV depending upon your OS

Or you can use this perl script (pipe your file into it):

#!/bin/perl

$opt_g=0;

sub epoch2time {
  ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = 
$opt_g==0?localtime(@_[0]):gmtime(@_[0]) ;

  sprintf("[ %d = %02d/%02d/%04d %02d:%02d:%02d %s]", 
@_[0],$mday,1+$mon,1900 + $year,$hour,$min,$sec,$opt_g?"GMT":"");

}

while (<>) {
        $_ =~ s/\b(\d{9,10})\b/epoch2time($1)/ge ;
        print $_ ;
}

--
Jerome Fleury
===
Archive at http://www.open.com.au/archives/radiator/
Announcements on radiator-announce at open.com.au
To unsubscribe, email 'majordomo at open.com.au' with
'unsubscribe radiator' in the body of the message.


More information about the radiator mailing list