pythonの日付処理と時間処理とunixtimestamp変換 Python
# python unixtime → date 変換
from datetime import datetime timezone timedelta
JST = timezone(timedelta(hours=+9) JST )
loc = datetime.fromtimestamp(1415542873 JST)
#utc = datetime.fromtimestamp(now timezone.utc)
print(loc)
# python unixtime → date 変換
import datetime
# print( datetime.datetime.fromtimestamp(1495248989) )
print( datetime.datetime.fromtimestamp(1495248989) )
#python timestamp表示
from datetime import *
import time
print (time.mktime( datetime.now().timetuple() ) )
#python 年月日時分秒を別々に取得
from datetime import datetime
now = datetime.now()
print(datetime.now().year)
print(datetime.now().month)
print(datetime.now().day)
print(datetime.now().hour)
print(datetime.now().minute)
print(datetime.now().second)
# 2 指定日付のunixtime取得
print(datetime(2018 1 12)) # ok