Perl中处理时间的函数有如下几种
1. time()函数:返回从1970年1月1日起累计的秒数
2. localtime()函数:获取本地时区时间
3. gmtime()函数:获取格林威治时间
当前时间和日期
localtime()函数:该函数在没有参数的情况下返回当前的时间和日期,以下9个符号代表不同的时间日期参数:


格林威治时间(GMT)
函数gmtime()与localtime()类似,但它返回标准格林威治时间

格式化日期和时间
可以使用localtime()函数的9个时间元素来输出需要指定的格式时间。格式化输出使用printf()函数。

新纪元时间(Epoch Time)
可以使用time()函数来获取新纪元时间,该函数返回从1970年1月1日起累计的秒数


POSIX函数strtime()
函数strtime()可以将时间格式化为我们想要的格式





网友评论