- use Encode;
- use Time::Local;
- (my $sec,my $min,my $hour,my $day,my $mon,my $year,my $weekday,my $yeardate,my $savinglightday) = (localtime(time));
- $sec = ($sec < 10)? "0$sec":$sec;
- $min = ($min < 10)? "0$min":$min;
- $hour = ($hour < 10)? "0$hour":$hour;
- $day = ($day < 10)? "0$day":$day;
- $mon = ($mon < 9)? "0".($mon+1):($mon+1);
- $year += 1900;
- my $log_time = "$year$mon$day";
- my $log_fulltime = "$year-$mon-$day $hour:$min:$sec "."week ".$weekday;
- my $log_filetime = "$year$mon$day$hour";
- my $log_newtime = "$year-$mon-$day $hour:$min:$sec";
- my $log_sec = "$year$mon$day$hour$min$sec";
- $edit_time = $log_newtime;
- $edit_time_compare = $edit_time;
- $edit_time_compare =~ s/-//g;
- $edit_time_compare =~ s/\\s//g;
- $edit_time_compare =~ s/://g;
- print $log_newtime."\\n";
- print $edit_time_compare."\\n";
- print $edit_time."\\n";
- #该片段来自于http://www.codesnippet.cn/detail/280120131958.html
来源: http://www.codesnippet.cn/detail/280120131958.html