How to get current date and time in Python
현재 시간 정보를 가져오는 파이썬 함수는 다들 알고 있듯이
> datetime.datetime.now()
from datetime import datetime
# datetime object containing current date and time
now = datetime.now()
print("now =", now)
# dd/mm/YY H:M:S
dt_string = now.strftime("%d/%m/%Y %H:%M:%S")
print("date and time =", dt_string)
국가 시간대를 적용하고 싶다면 아래와 같이 사용
> datetime.datetime.now(datetime.timezone.utc)
from datetime import datetime, timezone
now = datetime.now(timezone.utc)
저장용으로 남겨둔다.
www.programiz.com/python-programming/datetime/current-datetime
How to get current date and time in Python?
How to get current date and time in Python? In this article, you will learn to get today's date and current date and time in Python. We will also format the date and time in different formats using strftime() method. Video: Dates and Times in Python There
www.programiz.com
Why does datetime.datetime.utcnow() not contain timezone information?
datetime.datetime.utcnow() Why does this datetime not have any timezone info given that it is explicitly a UTC datetime? I would expect that this would contain tzinfo.
stackoverflow.com
www.44bits.io/ko/post/python-datatime-cheetsheet
파이썬 날짜시간 모듈(datetime) 치트시트
파이썬(Python)의 datatime 클래스를 사용하는 유용한 방법들을 소개합니다. 시간 계산에 필요한 용어와 동작원리도 함께 살펴봅니다.
www.44bits.io
BJ.

Ion Ceban @ionelceban 님의 사진, 출처: Pexels
'IT > 파이썬' 카테고리의 다른 글
파이썬 Mongoengine 에서 Document 삭제 방법 flask (0) | 2021.02.17 |
---|---|
파이썬 실행파일 만들기 - pyinstaller exe 실행파일 (0) | 2021.02.17 |
파이썬 flask REST API JSON 과 HTML form 처리 동시에 하기 (0) | 2021.02.14 |
파이썬 mongodb mongoengine 데이터 가져오기 (0) | 2021.02.14 |
파이썬 mongodb MongoEngine 사용시 filter 함수 (0) | 2021.02.14 |