from datetime import datetime
timenow = datetime.now() # Current Time
dt = timenow.strftime('%m-%d-%Y, %H:%M:%S') # datetime
print(dt)
04-11-2019, 13:20:17
year1 = timenow.strftime('%Y') # Year with century as a decimal number
print(year1)
2019
year2 = timenow.strftime('%y') # Year without century as a zero-padded decimal number
print(year2)
19
month1 = timenow.strftime('%m') # Month as a zero-padded decimal number
print(month1)
04
month2 = timenow.strftime('%b') # Month as locale’s abbreviated name
print(month2)
Apr
day1 = timenow.strftime('%d') # Day of the month as a zero-padded decimal number
print(day1)
11
hour = timenow.strftime('%H') # Hour (24-hour clock) as a zero-padded decimal number
print(hour)
13
minute = timenow.strftime('%M') # Minute as a zero-padded decimal number
print(minute)
20
seccond = timenow.strftime('%S') # Second as a zero-padded decimal number
print(minute)
17
time = timenow.strftime('%T') # time
print(time)
13:20:17
'Python > Python Programming' 카테고리의 다른 글
[Python] Send Slack Massages and upload file (0) | 2019.08.02 |
---|---|
jupyter notebook install (windows) 설치 (0) | 2019.07.27 |
[Python] 로그스탬프 UTC 한국시간 계산하기 (0) | 2019.07.02 |
[Python] Access Log 유니코드를 한글로 변환 (0) | 2019.04.18 |
파이썬(Python) 설치 (1) | 2019.03.17 |
[Python] ODBC driver를 이용한 mssql 연결 (0) | 2018.12.29 |
[Python] File Copy (파일복사) (0) | 2018.09.03 |
[Python] FTP TLS Download 다운로드 (0) | 2018.08.07 |