使用strftime返回可读的时间格式

2325阅读 0评论2012-03-21 努力小伙
分类:Python/Ruby


点击(此处)折叠或打开

  1. #!/usr/bin/perl
  2. # 来源: Lover的工具小屋
  3. # author: Lover

  4. use strict;
  5. use warnings;
  6. # 使用strftime来得到想要的时间格式,格式和命令date一模一样
  7. use POSIX qw(strftime);
  8. print strftime("%Y-%m-%d %H:%M:%S %Z",localtime()); # %Z 时区
会输出
2012-03-21 18:44:50 CST
上一篇:有关perl程序执行超时的处理办法
下一篇:mod_perl 2 配置和具体实例