filmov
tv
Code 46: strftime() in Python DateTime | Datetime Module | 365 Days of Code
Показать описание
strftime() in Python DateTime.
The strftime() method returns a string representing
date and time using date, time or datetime object.
The strftime() method takes one or more format codes
as an argument and returns a formatted string based on it.
Some commonly used format codes:
%m: Month as a zero-padded decimal number. Ex - 01,02,...12
%d: Day of the month as a zero-padded decimal. Ex - 01,02,...31
%Y: Year Ex - 2010,2019,...
%H: Hour (24-hour clock) as a decimal number. Ex - 0, 1,..,23
%M: Minute as a zero-padded decimal number. Ex - 00,01,..,59
%S: Second as a zero-padded decimal number. Ex - 00,01,..,59
"""
import datetime
print(curr_dt)
The strftime() method returns a string representing
date and time using date, time or datetime object.
The strftime() method takes one or more format codes
as an argument and returns a formatted string based on it.
Some commonly used format codes:
%m: Month as a zero-padded decimal number. Ex - 01,02,...12
%d: Day of the month as a zero-padded decimal. Ex - 01,02,...31
%Y: Year Ex - 2010,2019,...
%H: Hour (24-hour clock) as a decimal number. Ex - 0, 1,..,23
%M: Minute as a zero-padded decimal number. Ex - 00,01,..,59
%S: Second as a zero-padded decimal number. Ex - 00,01,..,59
"""
import datetime
print(curr_dt)