공부

[Python] timezone KST

승가비 2020. 4. 16. 00:40
728x90
# pip install pytz

from pytz import timezone
from datetime import datetime


fmt = "%Y-%m-%d %H:%M:%S %Z%z"
UTC = datetime.now(timezone('UTC'))
KST = datetime.now(timezone('Asia/Seoul'))

print UTC
print KST

print UTC.strftime(fmt)
print KST.strftime(fmt)

https://technote.kr/202

 

[04-3] Python - Timezone 변경하기

개인적으로 사용하고 있는 서버의 System time은 UTC(세계표준시간)로 설정되어 있다. KST로 설정하면 별다른 코드없이 바로 해당 시간 사용이 가능하겠지만 KST보다는 UTC로 운영하고 있다. 하지만 종종 코드상에..

technote.kr

 

728x90