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. easyui datagrid行编辑中数据联动

    easyui的datagrid中行内编辑使用数据联动.即:当编辑产品编号时,该行的产品名称自动根据产品编号显示出来. 在编辑中获取当前行的索引 function getRowIndex(target) ...

  2. CefSharp开发

    CefSharp是用chromium内核开发的.net版本浏览器工具.目前只支持X86模式.所以在调试的时候要把平台改为X86 CefSharp开发指引:https://ourcodeworld.co ...

  3. Python学习---Python下[字典]的学习

    Python中唯一的映射类型(哈希表)       -->Java中的HashMap<K,V> Python对key进行了哈希函数运算,根据计算的结果决定value的存储地址,所以字 ...

  4. 你是怎么调试 JavaScript 程序

    你是怎么调试 JavaScript 程序的?最原始的方法是用 alert() 在页面上打印内容,稍微改进一点的方法是用 console.log() 在 JavaScript 控制台上输出内容.嗯~,用 ...

  5. Linux 系统查看tomcat控制台命令

    前提进入tomcat/logs文件夹下 查看全部命令是:tail -f catalina.out 如果想查看具体文件的日志进入该文件所在目录然后命令如下: tail -f filename

  6. Java反编译工具Jad及插件JadClipse配置教程

    Jad是一个Java的一个反编译工具,和eclipse的插件JadClipse,二者结合可以方便的在eclipse中查看class文件的源代码. 下面介绍一下配置: 下载JadClipse,http: ...

  7. Linux关于scp命令

    声明:本文主要转自https://www.2cto.com/os/201503/379474.html scp主要应用场景如下: (1)必要时,每个季度或者每月将数据由这台服务器传输到另外一台,不过前 ...

  8. js获取给定时间的下一天

    //获取给定时间的下一天 yyyy-MM-dd格式 function getNextDay(d){ d = new Date(d); d = +d + 1000*60*60*24; d = new D ...

  9. Git如何从github上pull别人的项目

    1:使用git方式导入项目 菜单-File->import->Git->Projects from Git 2:选择某个服务器上的资源 3:选择需要pull的地址 后面需要自己加上 ...

  10. [转]C#如何获取客户端IP地址

    代码如下: /// <summary> /// 获取客户端IP地址    /// </summary> /// <returns></returns> ...