In [1]:
#example using the time module
import time
print time.strftime('%Y%m%d')
In [2]:
#alternatively, an example using the datetime module
import datetime
#sets the variable "today" as the datetime object.
today = datetime.datetime.today()
In [3]:
#today is a datetime object
today
Out[3]:
In [4]:
#print the string of the datetime object in the desired format
print today.strftime('%Y%m%d')
Great - thank you. Perfect for a project using Python & sqlite3 :-)
ReplyDelete