2018/07/14

[python] get current datetime

from datetime import datetime
datetime.today()                # get current date
datetime.today().year        # get current year
datetime.today().month    # get current month
datetime.today().day         # get current day
datetime.today().hour        # get current hour
datetime.today().strftime("%Y/%m/%d %H:%M:%S")  # get current date with format yyyy/mm/dd hh24:mm:ss

댓글 없음:

댓글 쓰기