programming-examples/python/Date/Generate a date and times as a string.py
2019-11-15 12:59:38 +01:00

9 lines
285 B
Python

import datetime
# Current time
now = datetime.datetime.now()
# Make a note of the date and time in a string
# Date and time in string : 2016-11-05 11:24:24 PM
datestr = "# In string: " + now.strftime("%Y-%m-%d %H:%M:%S %p") + "\n"
print()
print(datestr)
print()