总结:

time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f")

几个概念

时间戳:整型或float
time对象,datetime对象
字符串 := '2015-06-06 10:10:10'

时间戳<-->struct_time

time_struct = time.localtime(timestamp)
timestamp = time.mktime(time_struct)

struct_time<-->字符串

time.strftime("%Y-%m-%d %H:%M:%S", st)
time.strptime(st, "%Y-%m-%d %H:%M:%S")

时间戳<-->datetime

datetime.datetime.fromtimestamp(ts)
dt.timestamp()

datetime<-->字符串

dt.strftime("%Y-%m-%d %H:%M:%S.%f")
datetime.strptime(dt, "%Y-%m-%d %H:%M:%S.%f")
ps:datetime转time对象:datetimeObj.timetuple()

time,datetime,时间戳 时间格式转换的更多相关文章

  1. string转DateTime(时间格式转换)

    1.不知道为什么时间在数据库用varchar(8)来保存,例如"19900505",但是这样的保存格式在处理时间的时候是非常不方便的. 但是转换不能用Convert.ToDateT ...

  2. MySQL时间戳和时间格式转换函数

    MySQL时间戳和时间格式转换函数:unix_timestamp and from_unixtime unix_timestamp将时间转化成时间戳格式.from_unixtime将时间戳转化成时间格 ...

  3. SQL Server日期时间格式转换字符串详解 (详询请加qq:2085920154)

    在SQL Server数据库中,SQL Server日期时间格式转换字符串可以改变SQL Server日期和时间的格式,是每个SQL数据库用户都应该掌握的.本文我们主要就介绍一下SQL Server日 ...

  4. SQL Server日期时间格式转换字符串

    在SQL Server数据库中,SQL Server日期时间格式转换字符串可以改变SQL Server日期和时间的格式,是每个SQL数据库用户都应该掌握的.本文我们主要就介绍一下SQL Server日 ...

  5. Sql日期时间格式转换;取年 月 日,函数:DateName()、DATEPART()

    一.sql server2000中使用convert来取得datetime数据类型样式(全) 日期数据格式的处理,两个示例: CONVERT(varchar(16), 时间一, 20) 结果:2007 ...

  6. SQL Server日期时间格式转换字符串详解

    本文我们主要介绍了SQL Server日期时间格式转换字符串的相关知识,并给出了大量实例对其各个参数进行对比说明,希望能够对您有所帮助. 在SQL Server数据库中,SQL Server日期时间格 ...

  7. sql 日期时间格式转换

    Sql日期时间格式转换   sql server2000中使用convert来取得datetime数据类型样式(全) 日期数据格式的处理,两个示例: CONVERT(varchar(16), 时间一, ...

  8. [php基础]Mysql日期函数:日期时间格式转换函数详解

    在PHP网站开发中,Mysql数据库设计中日期时间字段必不可少,由于Mysql日期函数输出的日期格式与PHP日期函数之间的日期格式兼容性不够,这就需要根据网站实际情况使用Mysql或PHP日期转换函数 ...

  9. scala 时间格式转换(String、Long、Date)

    1)scala 时间格式转换(String.Long.Date) 1.时间字符类型转Date类型 [java] view plain copy import java.text.SimpleDateF ...

随机推荐

  1. [转]Java 运算符的优先级

    Java 运算符的优先级(从高到低) 优先级 描述 运算符 1 括号 ().[] 2 正负号 +.- 3 自增自减,非 ++.--.! 4 乘除,取余 *./.% 5 加减 +.- 6 移位运算 &l ...

  2. javascript讲解

    1. js介绍 js的全称 javascript     由布兰登 艾奇发明的 javascript和java是有区别的 javascript是一门前台语言,而Java 是后台语言 前台语言运行在客户 ...

  3. 关于rawurldecode PHP自动解码

    发表于: 2007-12-05 12:16:20   在网上找到资料说通过javascript传递参数时如果用了encodeURIComponent函数对参数进行编码,在PHP里面需要用 rawurl ...

  4. 利用新浪js接口根据ip地址获取实际地址

    1.核心:http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=json&ip=192.152.3.25 把这句话直接输入到浏览器 ...

  5. ffmpeg同步

    1:ffmpeg解码流程 拆包,构建队列,解码,同步,显示 //计算视频Frame的显示时间//获取ptspts = 0;//decodec video frameavcodec_decode_vid ...

  6. AVL树Python实现

    # coding=utf-8 # AVL树Python实现 def get_height(node): return node.height if node else -1 def tree_mini ...

  7. 深入分析Java Web技术内幕 修订版 pdf

    百度网盘:http://pan.baidu.com/s/1slHCCw9

  8. 解决Specifying a namespace in include()withou providing an app_name

    python3 Django 环境下,如果你遇到namespace没有注册以及在根目录下urls.py中的include方法的第二个参数namespace添加之后就出错的问题.请在[app_name] ...

  9. SQL SERVER2008 DBX Error: Driver could not be properly initialized

    raised exception class TDBXError with message 'DBX Error:  Driver could not be properly initialized. ...

  10. Ping ip能ping通,ping计算机名ping不通,网络共享不能访问

    名称 协议 端口 NetBIOS Name Service UDP 137 NetBIOS Datagram Service UDP 138 NetBIOS Session Service TCP 1 ...