UTC 오프셋

Python에서 날짜와 시간 다루기

Max Shron

Data Scientist and Author

Python에서 날짜와 시간 다루기

Python에서 날짜와 시간 다루기

Python에서 날짜와 시간 다루기

Python에서 날짜와 시간 다루기

Python에서 날짜와 시간 다루기

Python에서 날짜와 시간 다루기

UTC

# 관련 클래스 임포트
from datetime import datetime, timedelta, timezone
Python에서 날짜와 시간 다루기

UTC

# 관련 클래스 임포트
from datetime import datetime, timedelta, timezone

# 미국 동부 표준시(EST)
ET = timezone(timedelta(hours=-5))

# 타임존 인식 datetime dt = datetime(2017, 12, 30, 15, 9, 3, tzinfo = ET)
print(dt)
2017-12-30 15:09:03-05:00
Python에서 날짜와 시간 다루기

UTC

# 인도 표준시(IST)
IST = timezone(timedelta(hours=5, minutes=30))

# IST로 변환 print(dt.astimezone(IST))
2017-12-31 01:39:03+05:30
Python에서 날짜와 시간 다루기

타임존 조정 vs tzinfo 변경

print(dt)
2017-12-30 15:09:03-05:00

print(dt.replace(tzinfo=timezone.utc))
2017-12-30 15:09:03+00:00
# 원본을 UTC에 맞게 조정
print(dt.astimezone(timezone.utc))
2017-12-30 20:09:03+00:00
Python에서 날짜와 시간 다루기

UTC 오프셋

Python에서 날짜와 시간 다루기

Preparing Video For Download...