라벨이 datetime인 게시물 표시

파이썬[Python]: datetime - utcoffset 메서드

datetime 모듈 - datetime 클래스 - utcoffset 메서드(method) /// 설명 UTC 시간과 현지시간(타임존)의 차이를 나타냅니다. ※ 형식 datetime.utcoffset() reference https://docs.python.org/3/library/datetime.html#module-datetime /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 import  datetime   year  =  datetime.datetime.now().year month  =  datetime.datetime.now().month day  =  datetime.datetime.now().day hour  =  datetime.datetime.now().hour minute  =  datetime.datetime.now().minute second  =  datetime.datetime.now().second microsecond  =  datetime.datetime.now().microsecond   test_dt  =  datetime.datetime(year = year, month = month, day = day, hour = hour, minute = minute,                             second = second, microsecond = microsecond, tzinfo = None , fold = 0 )   print (test_dt.utcoffset())   # None   test_timezone  =  datetime.timezone(datetime.timedelta(hours = 9 ),  'KST' ) test_dt  =  datetime.datetime(year = year, month = month, day = day, hour = hour, minute = minute,   

파이썬[Python]: datetime - timetz 메서드

datetime 모듈 - datetime 클래스 - timetz 메서드(method) /// 설명 '시:분:초.마이크로초+타임존'를 반환합니다. ※ 형식 datetime.timetz() reference https://docs.python.org/3/library/datetime.html#module-datetime /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 import  datetime   year  =  datetime.datetime.now().year month  =  datetime.datetime.now().month day  =  datetime.datetime.now().day hour  =  datetime.datetime.now().hour minute  =  datetime.datetime.now().minute second  =  datetime.datetime.now().second microsecond  =  datetime.datetime.now().microsecond   test_timezone  =  datetime.timezone(datetime.timedelta(hours = 9 ),  'KST' )   test_dt  =  datetime.datetime(year = year, month = month, day = day, hour = hour, minute = minute,                             second = second, microsecond = microsecond, tzinfo = test_timezone, fold = 0 )   print (test_dt.timetz())   # 09:41:30.945714+09:00 Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9)

파이썬[Python]: datetime - time 메서드

datetime 모듈 - datetime 클래스 - time 메서드(method) /// 설명 '시:분:초.마이크로초'를 반환합니다. ※ 형식 datetime.time() reference https://docs.python.org/3/library/datetime.html#module-datetime /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 import  datetime   year  =  datetime.datetime.now().year month  =  datetime.datetime.now().month day  =  datetime.datetime.now().day hour  =  datetime.datetime.now().hour minute  =  datetime.datetime.now().minute second  =  datetime.datetime.now().second microsecond  =  datetime.datetime.now().microsecond   test_dt  =  datetime.datetime(year = year, month = month, day = day, hour = hour, minute = minute,                             second = second, microsecond = microsecond, tzinfo = None , fold = 0 )   print (test_dt.time())   # 16:41:40.720768   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: datetime - date 메서드

datetime 모듈 - datetime 클래스 - date 메서드(method) /// 설명 '년-월-일'을 반환합니다. ※ 형식 datetime.date() reference https://docs.python.org/3/library/datetime.html#module-datetime /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 import  datetime   year  =  datetime.datetime.utcnow().year month  =  datetime.datetime.utcnow().month day  =  datetime.datetime.utcnow().day hour  =  datetime.datetime.utcnow().hour minute  =  datetime.datetime.utcnow().minute second  =  datetime.datetime.utcnow().second microsecond  =  datetime.datetime.utcnow().microsecond   # KTC test_timezone  =  datetime.timezone(datetime.timedelta(hours = 9 ),  'KST' )   test_dt  =  datetime.datetime(year = year, month = month, day = day, hour = hour, minute = minute,                             second = second, microsecond = microsecond, tzinfo = test_timezone, fold = 0 )   print (test_dt.date())   # 2022-01-04   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Pytho

파이썬[Python]: datetime - fold 변수

datetime 모듈 - datetime 클래스 - fold 변수(variable) /// 설명 반복되는 일광 절약 시간제(Daylight saving time, DST)를 명확하게 하기 위해 사용됩니다. 0은 시간이 바뀌기 전, 1은 시간이 바뀐 후를 표현합니다. ※ 형식 datetime.fold reference https://docs.python.org/3/library/datetime.html#module-datetime /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 import  datetime   year  =  datetime.datetime.utcnow().year month  =  datetime.datetime.utcnow().month day  =  datetime.datetime.utcnow().day hour  =  datetime.datetime.utcnow().hour minute  =  datetime.datetime.utcnow().minute second  =  datetime.datetime.utcnow().second microsecond  =  datetime.datetime.utcnow().microsecond   # UTC test_timezone  =  datetime.timezone(datetime.timedelta(hours = 0 ),  'UTC' )   test_dt  =  datetime.datetime(year = year, month = month, day = day, hour = hour, minute = minute,                             second = second, microsecond = microsecond, tzinfo = test_timezone, fold = 0 )   print (test_dt.fold)   # 0   Colored by Color Scripter cs

파이썬[Python]: datetime - tzinfo 변수

datetime 모듈 - datetime 클래스 - tzinfo 변수(variable) /// 설명 datetime 객체에 전달된 tzinfo의 값을 표현합니다. 전달된 값이 없으면 None을 표현합니다. ※ 형식 datetime.tzinfo reference https://docs.python.org/3/library/datetime.html#module-datetime /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 import  datetime   year  =  datetime.datetime.utcnow().year month  =  datetime.datetime.utcnow().month day  =  datetime.datetime.utcnow().day hour  =  datetime.datetime.utcnow().hour minute  =  datetime.datetime.utcnow().minute second  =  datetime.datetime.utcnow().second microsecond  =  datetime.datetime.utcnow().microsecond   # Korean Standard Time: KST = UTC + 9 test_timezone  =  datetime.timezone(datetime.timedelta(hours = 9 ),  'KST' )   test_dt  =  datetime.datetime(year = year, month = month, day = day, hour = hour, minute = minute,                             second = second, microsecond = microsecond, tzinfo = test_timezone)   print (test_dt.tzinfo)   # KST   Colored by Color Scripter cs *

파이썬[Python]: datetime - microsecond 변수

datetime 모듈 - datetime 클래스 - microsecond 변수(variable) /// 설명 0 과 MAXYEAR 999999사이의 microsecond을 표현합니다. ※ 형식 datetime.microsecond reference https://docs.python.org/3/library/datetime.html#module-datetime /// 예제 1 2 3 4 5 6 7 8 import  datetime   test_today  =  datetime.datetime.today()   print (test_today)   # 2021-11-27 12:14:35.802450   print (test_today.microsecond)   # 802450   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: datetime - second 변수

datetime 모듈 - datetime 클래스 - second 변수(variable) /// 설명 0 과 59 사이의 second을 표현합니다. ※ 형식 datetime.second reference https://docs.python.org/3/library/datetime.html#module-datetime /// 예제 1 2 3 4 5 6 7 8 import  datetime   test_today  =  datetime.datetime.today()   print (test_today)   # 2021-11-27 12:11:21.732888   print (test_today.second)   # 21   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: datetime - minute 변수

datetime 모듈 - datetime 클래스 - minute 변수(variable) /// 설명 0 과 59 사이의 minute 을 표현합니다. ※ 형식 datetime.minute reference https://docs.python.org/3/library/datetime.html#module-datetime /// 예제 1 2 3 4 5 6 7 8 import  datetime   test_today  =  datetime.datetime.today()   print (test_today)   # 2021-11-27 12:09:46.171105   print (test_today.minute)   # 9   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: datetime - hour 변수

datetime 모듈 - datetime 클래스 - hour 변수(variable) /// 설명 0 과 23 사이의 hour을 표현합니다. ※ 형식 datetime.hour reference https://docs.python.org/3/library/datetime.html#module-datetime /// 예제 1 2 3 4 5 6 7 8 import  datetime   test_today  =  datetime.datetime.today()   print (test_today)   # 2021-11-27 12:08:21.986402   print (test_today.hour)   # 12   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: datetime - day 변수

datetime 모듈 - datetime 클래스 - day 변수(variable) /// 설명 1 과 해당 달(month)의 말일 사이의 day을 표현합니다. ※ 형식 datetime.day reference https://docs.python.org/3/library/datetime.html#module-datetime /// 예제 1 2 3 4 5 6 7 import  datetime   print (datetime.datetime.today())   # 2021-11-27 12:05:11.355165   test_calendar  =  datetime.datetime.fromisocalendar( 2021 ,  47 ,  6 ) print (test_calendar.day)   # 27   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: datetime - month 변수

datetime 모듈 - datetime 클래스 - month 변수(variable) /// 설명 1 과 12 사이의 month을 표현합니다. ※ 형식 datetime.month reference https://docs.python.org/3/library/datetime.html#module-datetime /// 예제 1 2 3 4 5 6 7 import  datetime   print (datetime.datetime.today())   # 2021-11-27 12:02:20.470072   test_calendar  =  datetime.datetime.fromisocalendar( 2021 ,  47 ,  6 ) print (test_calendar.month)   # 11   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: datetime - year 변수

datetime 모듈 - datetime 클래스 - year 변수(variable) /// 설명 MINYEAR 과 MAXYEAR 사이의 year을 표현합니다. ※ 형식 datetime.year reference https://docs.python.org/3/library/datetime.html#module-datetime /// 예제 1 2 3 4 5 6 7 import  datetime   print (datetime.datetime.today())   # 2021-11-27 12:03:22.746471   test_calendar  =  datetime.datetime.fromisocalendar( 2021 ,  47 ,  6 ) print (test_calendar.year)   # 2021   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: datetime - resolution 상수

datetime 모듈 - datetime 클래스 - resolution 상수(constant) /// 설명 객체를 비교할 수 있는 가장 작은 값입니다.(1 microseconds) ※ 형식 datetime.resolution reference https://docs.python.org/3/library/datetime.html#module-datetime /// 예제 1 2 3 4 5 6 7 8 9 import  datetime   test_resolution  =  datetime.datetime.resolution print (test_resolution)   # 0:00:00.000001   # related to this method ------------------------------ print (datetime.timedelta(microseconds = 1 )) # 0:00:00.000001   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: datetime - max 상수 (datetime)

datetime 모듈 - datetime 클래스 - max 상수(constant) /// 설명 달력이 표현할 수 있는 가장 늦은 시기입니다. ※ 형식 datetime.max reference https://docs.python.org/3/library/datetime.html#module-datetime /// 예제 1 2 3 4 5 6 7 8 9 import  datetime   test_max  =  datetime.datetime.max print (test_max)   # 9999-12-31 23:59:59.999999   # related to this method ------------------------------ print (datetime.datetime(datetime.MAXYEAR,  12 ,  31 ,  23 ,  59 ,  59 ,  999999 , tzinfo = None )) # 9999-12-31 23:59:59.999999   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: datetime - min 상수

datetime 모듈 - datetime 클래스 - min 상수(constant) /// 설명 달력이 표현할 수 있는 가장 이른 시기입니다. ※ 형식 datetime.min reference https://docs.python.org/3/library/datetime.html#module-datetime /// 예제 1 2 3 4 5 6 7 8 import  datetime   test_min  =  datetime.datetime.min print (test_min)   # 0001-01-01 00:00:00   # related to this method ------------------------------ print (datetime.datetime(datetime.MINYEAR,  1 ,  1 , tzinfo = None ))   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: datetime - time 클래스

datetime 모듈 - time 클래스(class) /// 설명 시간을 가지고 있는 단일 객체입니다. tzinfo는 tzinfo의 서브클래스이고, fold는 일광 절약 시간제(Daylight saving time, DST)와 관련 있는 것으로 0 또는 1 을 사용합니다. ※ 형식 class datetime.time(hour=0, minute=0, second=0, microsecond=0, tzinfo=None, *, fold=0) reference https://docs.python.org/3/library/datetime.html#module-datetime /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 14 import  datetime   # UTC test_timezone  =  datetime.timezone(datetime.timedelta(hours = 0 )) print (test_timezone)   # UTC   # Korean Standard Time: KST = UTC + 9 test_timezone  =  datetime.timezone(datetime.timedelta(hours = 9 )) print (test_timezone)   # UTC+09:00   # Korean Standard Time: KST = UTC + 9 test_timezone  =  datetime.timezone(datetime.timedelta(hours = 9 ),  'KST' ) print (test_timezone)   # KST   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: datetime - datetime 클래스

datetime 모듈 - datetime 클래스(class) /// 설명 날짜와 시간을 가지고 있는 단일 객체입니다.(year, month, day 인자는 요구되어집니다.) tzinfo는 tzinfo의 서브클래스이고, fold는 일광 절약 시간제(Daylight saving time, DST)와 관련 있는 것으로 0 또는 1 을 사용합니다. ※ 형식 class datetime.datetime(year, month, day, hour=0, minute=0, second=0, microsecond=0, tzinfo=None, *, fold=0) reference https://docs.python.org/3/library/datetime.html#module-datetime /// 예제 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 import  datetime   year  =  datetime.datetime.utcnow().year month  =  datetime.datetime.utcnow().month day  =  datetime.datetime.utcnow().day hour  =  datetime.datetime.utcnow().hour minute  =  datetime.datetime.utcnow().minute second  =  datetime.datetime.utcnow().second microsecond  =  datetime.datetime.utcnow().microsecond   test_dt  =  datetime.datetime(year = year, month = month, day = day, hour = hour, minute = minute,                             second = second, microsecond = microsecond, tzinfo = None

파이썬[Python]: datetime - utc 상수

datetime 모듈 - timezone 클래스 - utc 상수(constant) /// 설명 UTC timezone을 반환합니다. ※ 형식 timezone.utc reference https://docs.python.org/3/library/datetime.html#module-datetime /// 예제 1 2 3 4 5 6 7 8 9 10 11 import  datetime   # Korean Standard Time: KST = UTC + 9 test_timezone  =  datetime.timezone(datetime.timedelta(hours = 9 ),  'KST' ) print (test_timezone)   # KST   test_utc  =  test_timezone.utc print (test_utc)   # UTC   print (datetime.timezone(datetime.timedelta( 0 )))   # UTC   Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: datetime - fromutc 메서드

datetime 모듈 - timezone 클래스 - fromutc 메서드(method) /// 설명 UTC+offset 시간이 반환됩니다.(dt 는 UTC시간이고, dt 의 tzinfo는 원하는 timezone을 사용하시면 됩니다.) ※ 형식 timezone.fromutc(dt) reference https://docs.python.org/3/library/datetime.html#module-datetime /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 import  datetime   year  =  datetime.datetime.utcnow().year month  =  datetime.datetime.utcnow().month day  =  datetime.datetime.utcnow().day hour  =  datetime.datetime.utcnow().hour minute  =  datetime.datetime.utcnow().minute second  =  datetime.datetime.utcnow().second microsecond  =  datetime.datetime.utcnow().microsecond   # Korean Standard Time: KST = UTC + 9 test_timezone  =  datetime.timezone(datetime.timedelta(hours = 9 ),  'KST' ) print (test_timezone)   # KST   # UTC -> KST(UTC + 9) test_dt  =  datetime.datetime(year = year, month = month, day = day, hour = hour, minute = minute,                             second = second, microsecond = microsecond, tzinfo