【Python3】日付(datetime) <-> 文字列

import datetime

 

日付(datetime) -> 文字列

“{0:%Y-%m-%d %H:%M:%S}”.format(datetime.datetime.today())

 

文字列 -> 日付(datetime)

[POST] http://xxxxx/xxxx/?date=2015-04-20 11:44:25

p_date = request.POST[‘date’]

dt = datetime.datetime.strptime(p_date, ‘%Y-%m-%d %H:%M:%S’)

Leave a Comment.