Perl 教程 之 Perl 时间日期 3

简介: Perl 时间日期

Perl 教程 之 Perl 时间日期 3

Perl 时间日期

Perl中处理时间的函数有如下几种:

1、time() 函数:返回从1970年1月1日起累计的秒数
2、localtime() 函数:获取本地时区时间
3、gmtime() 函数: 获取格林威治时间

当前时间和日期

格林威治时间 (GMT)

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

实例

!/usr/bin/perl

$local_datestring = localtime();
print "本地时间日期为:$local_datestring\n";

$gmt_datestring = gmtime();
print "GMT 时间日期为:$gmt_datestring\n";
以上实例执行输出结果为:

本地时间日期为:Sun Jun 12 11:32:14 2016
GMT 时间日期为:Sun Jun 12 03:32:14 2016
从实例中我们可以看出,中国的时间和格林威治时间相差了8小时。

目录
相关文章
|
1月前
|
Python
619: 蟠桃记(python)
619: 蟠桃记(python)
|
3月前
|
Python
使用Python在本地生成助记词
使用Python在本地生成助记词
|
4月前
|
Python
Python喜羊羊
Python喜羊羊
41 0
|
9月前
|
机器学习/深度学习 数据采集 人工智能
【python简单介绍】
【python简单介绍】
56 0
|
10月前
|
安全 Python
我在Python的艳阳里,大雪纷飞
pygame.draw.circle 是一个根据颜色、位置、半径绘制圆形图案的方法,我们用它来绘制白色的圆点作为雪花。
我在Python的艳阳里,大雪纷飞
|
数据库 Python
Python分享-with做了什么事?
Python分享-with做了什么事?
python
alink
75 0
|
Python
Python:使用2to3将Python2转Python3
Python:使用2to3将Python2转Python3
85 0
|
编解码 数据处理 索引
python xarray 简单介绍
python xarray 简单介绍
|
SQL Java 关系型数据库
数据持久化技术(Python)的使用
数据持久化技术(Python)的使用