如下所示:
[removed]
function createTime(v){
var date = new Date(v);
var y = date.getFullYear();
var m = date.getMonth()+1;
m = m<10?'0'+m:m;
var d = date.getDate();
d = d<10?("0"+d):d;
var h = date.getHours();
h = h<10?("0"+h):h;
var M
Python项目中很多时候会需要将时间在Datetime格式和TimeStamp格式之间转化,又或者你需要将UTC时间转化为本地时间,本文总结了这几个时间之间转化的函数,供大家参考。
一、Datetime转化为TimeStamp
def datetime2timestamp(dt, convert_to_utc=False):
''' Converts a datetime object to UNIX timestamp in milliseconds. '''
if isin