Time Series#

Timestamp#
Datetime#
from datetime import datetime
now()#
The now() method returns the current date and time as a datetime object.
datetime.now()
datetime.datetime(2025, 8, 13, 22, 30, 10, 316953)
strftime()#
The strftime() method returns the time in a string format.
To extract specific components from the string representation of a datetime object, use a percentage sign (%) followed by a corresponding character from the following table.
%Y: Year with century as a decimal number.
datetime.now().strftime('%Y')
'2025'
%y: Year without century as a decimal number [00,99]
datetime.now().strftime('%y')
'25'
%m: Month as a decimal number [01,12]
datetime.now().strftime('%m')
'08'
%d: Day of the month as a decimal number [01,31]
datetime.now().strftime('%d')
'13'
%H: Hour (24-hour clock) as a decimal number [00,23]
datetime.now().strftime('%H')
'22'
%I: Hour (12-hour clock) as a decimal number [00,11]
datetime.now().strftime('%I')
'10'
%M: Minute as a decimal number [00,59]
datetime.now().strftime('%M')
'30'
%S: Second as a decimal number [00,61].
datetime.now().strftime('%S')
'10'
Year and Month
datetime.now().strftime('%Y %m')
'2025 08'
Year, Month, and Day
datetime.now().strftime('%Y %m %d')
'2025 08 13'
Year, Month, Day, and Hour
datetime.now().strftime('%Y %m %d %H')
'2025 08 13 22'
datetime.now().strftime('%Y %m %d %H %M')
'2025 08 13 22 30'
Year, Month, Day, Hour, and Second
datetime.now().strftime('%Y %m %d %H %M %S')
'2025 08 13 22 30 10'