python> datetime> yyyy / mm / dd, hh: nn: ss format print> today = datetime.datetime.today () / print today.strftime ("% Y /% m /% d,% H:% M:" % S ")

I want to print the current time in yyyy / mm / dd, hh: nn: ss format.

Reference http://docs.python.jp/2/library/datetime.html

http://ideone.com/bs3buK

test.py


import datetime

today = datetime.datetime.today()
yymmddhhnnss = today.strftime("%Y/%m/%d,%H:%M:%S")
print yymmddhhnnss

result


2015/12/01,03:44:30

It seems to be UTC because I ran it with ideone.

Recommended Posts

python> datetime> yyyy / mm / dd, hh: nn: ss format print> today = datetime.datetime.today () / print today.strftime ("% Y /% m /% d,% H:% M:" % S ")
python> datetime> Get the datetime (eg 20151130) format string> print today.strftime ("% Y% m% d") / print "{:% Y% m% d}" .format ( today)
Python / datetime> Implementation to convert YYYYMMDD format to YYYY / MM / DD