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 }
In reply to Re^2: Directory creation with current Date
by ZlR
in thread Directory creation with current Date
by samv74
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |