如何以文本格式转换日期:
23.10.2011 11:35:00
到时间戳?
解决方法
使用
Time::Local可以做到:
use Time::Local; my $date = '23.10.2011 11:35:00'; my ($mday,$mon,$year,$hour,$min,$sec) = split(/[\s.:]+/,$date); my $time = timelocal($sec,$mday,$mon-1,$year); print $time,"\n",scalar localtime $time;
输出:
1319362500 Sun Oct 23 11:35:00 2011