[py]time模块

时间戳是一串字符串

time.time()
时间戳是指格林威治时间1970年01月01日00时00分00秒(北京时间1970年01月01日08时00分00秒)起至现在的总毫秒数。通俗的讲, 时间戳是一份能够表示一份数据在一个特定时间点已经存在的完整的可验证的数据。

unix的生日: unix time

肯·汤普逊 创造了unix,以创造出unix时间为unix time。(肯创造了unix+B语言, 丹尼斯基于B语言创造了C语言)

在用ng的date过滤服务的时候时间戳0会转换成1970-01-01 08:00:00;
是因为起源于UNIX系统,以Unix诞生的时间为参照确定的,UNIX认为1970年1月1日0点是时间纪元,现代计算机(电话,电子设备)时间以1970 年 1 月 1 日的 08:00为基准,
在时间转换时,或者时间重置时都会出现这个时间值,unix时间戳零点是 1970年1月1日0点整(utc),北京是gmt 8所以变成八点。

1970-01-01 08:00:00 到现在过了多少s, 方便了时间用字符串表示。

GTM 和UTC是一个意思

太阳升起的地方, 相当于给地球划了个开始位置 , 为了确保全球人譬如12点就是中午,大家都是这样,所以有了时区的概念。GMT+8 UTC8 多是等同的。
格林威治平时(英语:Greenwich Mean Time,GMT)是指位於英國倫敦郊區的皇家格林威治天文台當地的平太阳时,因為本初子午線被定義爲通過那裡的經線。

时间的表示格式UTC/GMT/ISO


var newDate = new Date();
newDate.setTime(timestamp3 * 1000);


console.log(newDate.toDateString()); // Wed Jun 18 2014 

console.log(newDate.toGMTString()); // Wed, 18 Jun 2014 02:33:24 GMT 

console.log(newDate.toISOString()); // 2014-06-18T02:33:24.000Z

console.log(newDate.toJSON());      // 2014-06-18T02:33:24.000Z 

console.log(newDate.toLocaleDateString()); // 2014年6月18日 

console.log(newDate.toLocaleString());     // 2014年6月18日 上午10:33:24 

console.log(newDate.toLocaleTimeString()); // 上午10:33:24 

console.log(newDate.toString());     // Wed Jun 18 2014 10:33:24 GMT+0800 (中国标准时间)

console.log(newDate.toTimeString()); // 10:33:24 GMT+0800 (中国标准时间) 

console.log(newDate.toUTCString());  // Wed, 18 Jun 2014 02:33:24 GMT

- 这种格式是iso时间格式
"datetime": "2018-12-24T01:22:59.00Z",

python中的iso时间


https://cloud.tencent.com/developer/ask/34664

python操作时间:格式化+时间delta(间隔)的计算

time偏系统
datetime可以理解为基于time的封装,高级了不少。
参考:
https://m.pythontab.com/article/1207

posted @ 2018-12-24 17:42  mmaotai  阅读(661)  评论(0编辑  收藏  举报