use perl to get timestamp

[不指定 2009/10/30 08:48 | by askwan ]
in different  context have different value
eg:
saclar context
print scalar (localtime);

then output :
Thu Oct 29 18:50:01 2009

but in list context ;
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =localtime(time);
$sec    0 ~ 59
$min    0 ~ 59
$hour  0 ~ 23
$mday   1~31
$mon     0 ~ 11
$year   after 1900,it passed years
$wday    0 ~ 6
$yday    0 ~365
$isdst   insignificant for me

can use this to get timestamp

output:
2009-10-29 19:2:40

have some defect ablove,use this

output:
2009-10-29 19:02:45

you can also use POSIX functions:
eg


output:
2009-10-29 11:10:44
2009-10-29 19:10:44

作者:askwan@『AskWan』
地址:http://www.askwan.com/use_perl_to_get_timestamp_localtime_strftime/
可以转载,转载时请以链接形式注明作者和原始出处及本声明!

Scripts | Comments(0) | Trackbacks(0) | Reads(143)
收藏到网摘:百度搜藏 Google书签 Yahoo收藏 新浪ViVi收藏夹 365天天网摘 天极网摘 我摘·网摘·网络书签 POCO网摘 和讯网摘 Bolaa博拉博客收录中心 天下图摘
Add a comment
Emots
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
Enable HTML
Enable UBB
Enable Emots
Hidden
Remember
Nickname   Password   Optional
Site URI   Email   [Register]