Python date1
datetime
Python date and time module.
To use this, please import datetime
import datetime
Sample
import datetime
# Date
today = datetime.date.today()
todaytime = datetime.datetime.today()
print(today)
print(todaytime)
# We can get element
print(dir(today))
print(today.year)
print(today.day)
print(today.weekday())
print(today.isoformat())
print(todaytime.strftime("%Y/%m/%d %H:%M:%S"))
Result
2016-05-02 2016-05-02 09:42:19.927371 ['__add__', '__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__ne__', '__new__', '__radd__', '__reduce__', '__reduce_ex__', '__repr__', '__rsub__', '__setattr__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', 'ctime', 'day', 'fromordinal', 'fromtimestamp', 'isocalendar', 'isoformat', 'isoweekday', 'max', 'min', 'month', 'replace', 'resolution', 'strftime', 'timetuple', 'today', 'toordinal', 'weekday', 'year'] 2016 2 0 2016-05-02 2016/05/02 09:42:19
