Date format

From Rosetta Code
Revision as of 18:59, 3 August 2007 by rosettacode>Jimbojw (New page: {{task}} Format a given date. ==Python== Category:Python Formatting rules: http://docs.python.org/lib/module-time.html (strftime) from datetime import * # Print today's date: ...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Task
Date format
You are encouraged to solve this task according to the task description, using any language you may know.

Format a given date.

Python

Formatting rules: http://docs.python.org/lib/module-time.html (strftime)

from datetime import *

# Print today's date:
today = date.today()
print "Today is: ", today.strftime('%B %d, %Y')

# Print tomorrow's date:
tomorrow = today + timedelta( days=1 )
print "Tomorrow is: ", tomorrow.strftime('%B %d, %Y')