[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Condor-users] When was 1189480839?

On Thu 07-09-27 20:10, Todd Tannenbaum wrote:
> One solution that can work anywhere you have perl.  Save the following
> tiny script into a file - I call it "ctime".  Then invoke as
>    ctime <epoch time(s)> 
> and you'll get a human date out.
> #!/usr/bin/env perl
> use Time::CTime;
> foreach my $arg (@ARGV) {
>     print ctime( $arg );
> }

I hadn't heard of a Perl module called Time::CTime; it doesn't exist
on the systems I've looked at, though you can install it via CPAN.
(There's a ctime function in Time::localtime, but it doesn't take
any arguments.)

But you don't need to use any modules at all.  I usually use this:

    % perl -e 'print scalar localtime 1189480839, "\n"'
    Mon Sep 10 20:20:39 2007

which I could easily wrap in a script if I got tired of typing it.
Change 'localtime' to 'gmtime' if you want UTC.

As somebody else mentioned, the "date" cammand can do this:

    $ date -d @1189480839
    Mon Sep 10 20:20:39 PDT 2007

but only if you have the GNU date command ("date --version" to check
this).  On Linux, you have GNU date; on other Unix-like systems,
/bin/date most likely isn't GNU date, but you may have it installed
somewhere else.

Keith Thompson <kst@xxxxxxxx>  San Diego Supercomputer Center
<http://users.sdsc.edu/~kst/>  858-822-0853
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"