What is returned by datetime(1970, 1, 1).strftime(‘%y-%d-%b’) in Python?
In order to run this statement we need to import datetime method first.
datetime creates an object of the class datetime. Here it is instantiated with the date 1970/1/1. Class name and object name are the same ( don’t get confused)
The strftime()
method returns a string representing date and time using date, time or datetime object. This resulting in a specific printout of the date(time).
y – > Year without century
d – > Day in syntax
b- > Abbreviated month name
The output will be 70-01-Jan
>>>from datetime import datetime >>>print(datetime(1970, 1, 1).strftime('%y-%d-%b') 70-01-Jan
Subscribe
Login
Please login to comment
0 Discussion