in reply to Weird Time: localtime shows wrong month
$mon is the month itself, in the range 0..11 with 0 indicating January and 11 indicating DecemberSo your code should look like this
my ($day, $month, $year) = (localtime)[3..5]; $year += 1900; ## increase $month to get desired output $month++; my $date = "$year-$month-$day"; print "$date\n"; $date = localtime; print "$date\n"; __output__ 2004-5-17 Mon May 17 10:41:08 2004
_________
broquaint
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Weird Time: localtime shows wrong month
by jfroebe (Parson) on May 17, 2004 at 03:48 UTC |