article

Sunday, May 29, 2016

Python Date and time Example code

Python Date and time Example code
 
#!/usr/bin/python
import time;  # This is required to include time module.

ticks = time.time()
print "Number of ticks since 12:00am, January 1, 1970:", ticks


localtime = time.localtime(time.time())
print "Local current time :", localtime

#formated time
localtime = time.asctime( time.localtime(time.time()) )
print ("Local current time :", localtime)

#Getting calendar for a month
import calendar
cal = calendar.month(2016, 2)
print ("Here is the calendar:")
print (cal)

Related Post