1. Home
  2. Computing & Technology
  3. Python

How To Create A HTML Calendar In Python Dynamically

From Al Lukaszewski, for About.com

3 of 10

A Day Called "Today"

Starting the main() function, let's ask datetime for the time.

def main():
     today = datetime.datetime.date(datetime.datetime.now())

Curiously, the datetime module has a datetime class. It is from this class that we call two objects: now() and date(). The method datetime.datetime.now() returns an object containing the following information: year, month, date, hour, minute, second, and microseconds. Of course, we have no need for the time information. To cull out the date information alone, we pass the results of now() to datetime.datetime.date() as an argument. The result is that today now contains the year, month, and date separated by em-dashes.

Explore Python
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Python
  4. Web Development
  5. Python and HTML - HTML Calendars in Python - A Day Called "Today"

©2009 About.com, a part of The New York Times Company.

All rights reserved.