in reply to Re: Directory creation with current Date
in thread Directory creation with current Date
Usually I want to avoid the load of the POSIX module so here is what i do :
Update: I guess it's better with sprintf, like mkirank does :$formatted_date = now_date() ; sub now_date { my @now = localtime ; my $now_day = $now[3] ; my $now_year = $now[5] + 1900 ; my $now_month = $now[4] + 1 ; if ($now_month < 10) { $now_month = "0".$now_month } if ($now_day < 10) { $now_day = "0".$now_day } my $now_scal = join "-", ( $now_year, $now_month, $now_day ) ; return $now_scal ; }
More Update: As demerphq says it could in the end very well be much better to use POSIX qw(strftime)sub now_date { my @now = localtime ; my $now_day = $now[3] ; my $now_year = $now[5] + 1900 ; my $now_month = $now[4] + 1 ; $now_scal = sprintf "%04d-%02d-%2d", $now_year , $now_month ,$now_ +day ; return $now_scal }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Directory creation with current Date
by demerphq (Chancellor) on Jan 19, 2005 at 15:28 UTC | |
by ZlR (Chaplain) on Jan 19, 2005 at 20:23 UTC | |
by demerphq (Chancellor) on Jan 19, 2005 at 21:20 UTC | |
by ZlR (Chaplain) on Jan 19, 2005 at 22:19 UTC | |
by demerphq (Chancellor) on Jan 19, 2005 at 22:35 UTC |