Python datetime

import datetime
 
now = datetime.datetime.now()
 
print
print "Current date and time using str method of datetime object:"
print str(now)
 
print
print "Current date and time using instance attributes:"
print "Current year: %d" % now.year
print "Current month: %d" % now.month
print "Current day: %d" % now.day
print "Current hour: %d" % now.hour
print "Current minute: %d" % now.minute
print "Current second: %d" % now.second
print "Current microsecond: %d" % now.microsecond
 
print
print "Current date and time using strftime:"
print now.strftime("%Y-%m-%d %H:%M")
  1. I’ll right away grab your rss feed as I can’t in finding your email subscription link or newsletter service. Do you have any? Kindly let me understand in order that I may subscribe. Thanks.

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>