PyPI for Python 3.7

import datetime

https://docs.python.org/3.7/library/datetime.html

timedelta Object

https://docs.python.org/3.7/library/datetime.html#timedelta-objects

Constructor:

datetime.timedelta(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0)

It also has a lot of operations. See the Documents for detail.

date Object

https://docs.python.org/3.7/library/datetime.html#date-objects

Datetime object is a combination of a date and a time. I like to use datetime object instead.

datetime Object

https://docs.python.org/3.7/library/datetime.html#datetime-objects

Constructor:

  • datetime.datetime(year, month, day, hour=0, minute=0, second=0, microsecond=0, tzinfo=None, *, fold=0)
  • datetime.datetime.fromtimestamp(timestamp, tz=None),By timestamp
  • datetime.datetime.combine(date, time, tzinfo),Combine date object and time object
  • datetime.datetime.strptime(date_string, format),By string and format

Ordinal Date is the proleptic Gregorian ordinal of the date. It is the count from 0001-01-01, just like timestamp.

Instance methods:

(Notice: a is the name of a exist datetime object)

  • a.replace(), Return a datetime with the same attributes, except for those attributes given new values.
  • a.astimezone(), Return a datetime object with the timezone you give.
  • a.timetuple(), Return a tuple. You can pick up what you need by index or others.
  • a.toordinal(), Return the ordinal.
  • a.timestamp(), Return the timestamp.
  • a.strftime(format), Return the format string.

timezone Object

https://docs.python.org/3.7/library/datetime.html#timezone-objects

  • datetime.timezone(offset), The offset attribute must be timedelta.

String format:

(strftime --> string from time. strptime())

https://docs.python.org/3.7/library/datetime.html#strftime-and-strptime-behavior

Directive Tips Meaning Example
%Y Year 4 bits Year 0001, 0002,..., 2019
%m Month 1/2 bits Month 01, 02, ..., 12
%d Day 1/2 bits Day 01, 02, ..., 31
%H Hour 2 bits Hour 00, 01, ..., 23
%M Minute 2 bits Minute 00, 01, ..., 59
%S Second 2 bits Second 00, 01, ..., 59
%w Week 1 bit, 0 for Sun. and 6 is Sat. 0, 1, ..., 6

PyPI - Datetime的更多相关文章

  1. python模块概况,json/pickle,time/datetime,logging

    参考: http://www.cnblogs.com/wupeiqi/articles/5501365.html http://www.cnblogs.com/alex3714/articles/51 ...

  2. python模块知识一 自定义模块、time、datetime时间模块

    第五章 模块 1.自定义模块: 模块分类: 内置模块(标准库)-- python解释器自带的.py文件(模块) 第三方模块(各种大神写的)-- 需要额外下载(并发编程pypi) 自定义模块(自己写的) ...

  3. 自定义模块,time,datetime以及random

    自定义模块,time,datetime以及random 1.自定义模块 自定义一个模块 import #导入 (拿工具箱) 模块分类 1.内置模块(标准库) --python解释器自带的.py文件(模 ...

  4. Python模块01/自定义模块/time模块/datetime模块/random模块

    Python模块01/自定义模块/time模块/datetime模块/random模块 内容大纲 1.自定义模块 2.time模块 3.datetime模块 4.random模块 1.自定义模块 1. ...

  5. C# DateTime与时间戳转换

    C# DateTime与时间戳的相互转换,包括JavaScript时间戳和Unix的时间戳. 1. 什么是时间戳 首先要清楚JavaScript与Unix的时间戳的区别: JavaScript时间戳: ...

  6. C# DateTime日期格式化

    在C#中DateTime是一个包含日期.时间的类型,此类型通过ToString()转换为字符串时,可根据传入给Tostring()的参数转换为多种字符串格式. 目录 1. 分类 2. 制式类型 3. ...

  7. 在面试中忽然发现DateTime的一些...

    今天说说我面试中碰到的一个小问题,在我问起DateTime为什么无法赋值NULL值,一般第一反应都认为它是值类型,不是引用类型,但随后我查阅了度娘自我学习到它是结构类型,那么随之而然就无法赋值NULL ...

  8. LINQ to SQL语句(14)之Null语义和DateTime

    Null语义 说明:下面第一个例子说明查询ReportsToEmployee为null的雇员.第二个例子使用Nullable<T>.HasValue查询雇员,其结果与第一个例子相同.在第三 ...

  9. .NET DateTime类型变量作为参数时设置默认值

    一个小的 Tips. .NET 中函数参数的默认值需要是编译时常量.如果参数是引用类型,可以设置Null,如果是值类型,可以设置相应的编译时常量,如整型可以用整数,但对于DateTime(结构体,值类 ...

随机推荐

  1. windows10 蓝牙(Bluetooth®)设备删除失败解决方案

    某次更新后蓝牙鼠标突然断线无响应,于是尝试删除设备后重新配对,但是出现了删除失败: 这时候可以这样解决: 进入设备管理器(Win+X 设备管理器) 点击 查看 (在最上面一行),选择"显示隐 ...

  2. 《Tomcat与Java Web开发技术详解》思维导图

    越想构建上层建筑,就越觉得底层基础很重要.补课系列. 书是良心书,就是太基础了,正适合补课. [纯文字版] Tomcat与Java Web开发技术详解 Servlet Servlet的生命周期 初始化 ...

  3. slider.js 滑动和点击事件在firefox下报错 event is not defined

    在使用layui的slider滑块控件的时候,firefox遇到了event is not defined 的情况.追究原因是因为layui的layui.js 的滑块功能依赖于silder.js,而官 ...

  4. WebExtensions小例

    一:简述 扩展是修改Web浏览器功能的代码位.它们使用标准的Web技术(JavaScript,HTML和CSS)以及一些专用的JavaScript API编写.其中,扩展程序可以向浏览器添加新功能或更 ...

  5. SchemaSpy

    SchemaSpy https://github.com/schemaspy/schemaspy/releases https://sourceforge.net/projects/schemaspy ...

  6. 200. Number of Islands + 695. Max Area of Island

    Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surro ...

  7. react开发中如何使用require.ensure加载es6风格的组件

    其实用的babel,在浏览器端就应该可以加载,之前少了个default: require.ensure([],(require) => { let A = require('./a.js').d ...

  8. 总结PHP删除字符串最后一个字符的三种方法

    一.前言 从数据库中select()读取一对多的信息时,经常需要将取出的数组用某个特定的字符分割,然后拼接成字符串. 常见的语法格式: foreach ($arr as $key => $val ...

  9. Linux学习总结(二) 网络配置-NAT方式静态IP配置篇

    一:DHCP 服务验证 1: 之前我们在里面已经装好了centos,当时我们选择的组网方式为NAT方式,那么我们怎么样如何快速实现虚拟机系统访问外网呢?能不能直接上网呢,来我们试一下ping baid ...

  10. 第六章.MyBatis缓存结构

    一级缓存 测试案例: MyBatisTest.java //缓存 @Test public void testFindCustomerCache1() throws Exception{ SqlSes ...