Print the current date:
#!/usr/bin/env python import time tm = time.localtime() print( "%4d-%02d-%02d" % ( tm.tm_year, tm.tm_mon, tm.tm_mday)) # # produces: 2016-12-08 #
Here is the complete localtime structure:
(tm_year=2010, tm_mon=11, tm_mday=3, tm_hour=14, tm_min=18, tm_sec=34, tm_wday=2, tm_yday=307, tm_isdst=0)