#!/usr/bin/perl
##
## utime.pl -- unix timestamp <==> date
##
## san2(at)linuxchannel.net
##
## usage : $0 'YYYY MM DD HH:II:SS'
## or
## $0 1073921077
use POSIX;
$ARGS = $ARGV[0];
if($ARGS =~ /^[0-9]+$/)
{
$utime = $ARGS;
}
elsif($ARGS)
{
$ARGS =~ s/[^0-9]+/ /g;
($yy,$mm,$dd,$hh,$ii,$ss) = split(/\s+/,$ARGS);
$utime = mktime($ss,$ii,$hh,$dd,$mm-1,$yy-1900);
}
else
{
$utime = time;
}
$udate = localtime($utime);
print $utime,' => ',$udate,"\n";
exit;
|