Recent Posts
Recent Comments
Link
«   2025/12   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
Archives
Today
Total
관리 메뉴

JIHYUN JEONG

[파이썬/Python] datetime, pytz 모듈 (timezone Asia Seoul 타임존 서울) 현재시간으로 하기 본문

Information Technology/Python

[파이썬/Python] datetime, pytz 모듈 (timezone Asia Seoul 타임존 서울) 현재시간으로 하기

StopHyun 2019. 12. 1. 18:05

 

datetime, pytz 모듈 을 활용하여 timezone Asia Seoul 타임존 서울 기준으로 현재시간을 활용해보겠습니다.

 

 

1
2
3
4
5
6
7
8
import datetime
from pytz import timezone
 
time_now = datetime.datetime.now(timezone('Asia/Seoul'))
print(time_now)
 
time_now_str = str(time_now)
print(time_now_str[:19])
cs

혹시나 현재 시간이 길다면 아래처럼 문자열로 해당 시,분,초 까지 슬라이스 해서 쓸 수 도 있습니다.

 

Comments