Front page | perl.beginners |
Postings from March 2002
Date format again
Thread Next
From:
Troy May
Date:
March 3, 2002 00:45
Subject:
Date format again
Message ID:
LOBBINEJDCHCGAJGGIFCIECMDGAA.tmay@sierrasoho.org
Hello, this guy finally emailed his script to me. The problem he is having
is with "$year". Here's the dating part of the code:
---------------------------------------
$date = `/bin/date`;
chop($date);
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
$thisday = (Sun,Mon,Tue,Wed,Thu,Fri,Sat)[(localtime) [6]];
$s = (localtime)[0];
$m = (localtime)[1];
$m = ($m + 35) ;
$h = (localtime)[2];
if ($m >=60)
{
$m = ($m - 60);
$h = ($h + 1);
}
if ($h >=24)
{
$h = 1;
}
else
{
$h = ($h + 10) ;
}
$month = (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec)[(localtime)[4]];
$year = (localtime)[5];
$year = ($year + 1900);
$day = (localtime)[3];
# this coding is creating problem
($sec,$min,$hour,$mday,$mon,$year,undef,undef,undef) = localtime();
$mon++; # adjust from 0-11 to 1-12
$year %= 100;
$theDate = sprintf("%02u%02u%02u", $mday, $mon, $year);
------------------------------------------
Now, when he prints "$theDate", everything is ok with it (format-030302).
But when he prints just "$year" it displays "2" instead of "2002"
Any ideas?
Thread Next
-
Date format again
by Troy May