I'm sorry for the ultra-small story, but as a memo for myself regarding the notation procedure
#Get time stamp
from datetime import datetime
from pytz import timezone
utc_now = datetime.now(timezone('UTC'))
jst_now = utc_now.astimezone(timezone('Asia/Tokyo'))
ts = jst_now.strftime("%Y%m%d-%H%M%S")
print(ts)
20200106-182252
This time, I used this format for the purpose of creating a part of the unique file name, but if you rewrite the part of "% Y% m% d-% H% M% S"
, you can do various things. It can be applied to patterns.
Recommended Posts