faqts : Computers : Programming : Languages : Python : Snippets : Date / Time

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

20 of 21 people (95%) answered Yes
Recently 9 of 10 people (90%) answered Yes

Entry

Query system date

Jul 5th, 2000 10:00
Nathan Wallace, unknown unknown, Hans Nowak, Snippet 138, ScherBi


"""
Packages: basic_applications.date_and_time
"""
"""
I am new to python and I am trying to figure out how to return the
computers system date and time and then format it as MM-DD-YYYY.  I have
searched the documentation up and down and have not found anything about
how to accomplish this.  Any help would be greatly appeciated.
"""
import time
print time.strftime("%m-%d-%Y", time.localtime(time.time()))
# e.g. '09-09-2020'
""" See the docs on the time module for more info. """