用Python将datetime.date转换为UTC时间戳
>>> d = datetime.date(2011,01,01)>>> datetime.datetime.utcfromtimestamp(time.mktime(d.timetuple()))datetime.datetime(2010, 12, 31, 23, 0)
from pytz import utc, timezonefrom datetime import datetimefrom time import mktime input_date = datetime(year=2011, month=1, day=15)
mktime(utc.localize(input_date).utctimetuple())
mktime(timezone('US/Eastern').localize(input_date).utctimetuple())
相关分类