https://zhidao.baidu.com/question/518839054910675165.html
https://zhidao.baidu.com/question/1644839377324350180.html
https://blog.csdn.net/August1226/article/details/80620924
二.
cashloan里面:
cashloanadmin里面: G:\pythonProject-4\CashLoanAdmin\common\time_switch.py
import time
def time_transformate(timestamp):
"""毫秒时间戳转换成 2016-05-05 20:28:54 这种格式的时间"""
timestamp = int(timestamp)
time_local = time.localtime(timestamp/1000)
data = time.strftime("%Y-%m-%d %H:%M:%S", time_local)
return data
时间戳可简单理解为自1970/01/01/ 00:00:00 到现在经过的秒数,如果要计算日期运算,因为涉及到润年,一般使用语言自带的库实现比较简单和高效。但如果只是取时间即时分秒,完全可以不用依赖库,通过模运算和取整运算的方式实现,并且性能比内部库函数效率更高。
运行结果,100万次
1000万次
性能快了接近200%,如果有涉及到大数据分析场景,百万甚至千万级别次的调用时,该算法还是有意义的