0
import datetime
today = datetime.date.today()
print ('Today is: ' + str(today))

//returns Today is: 2016-10-06

How could I manipulate the output to look like this: "Today is: October 6, 2016"

EJSuh
  • 185
  • 1
  • 2
  • 9

3 Answers3

4

Based on datetime.strftime() documentation:

import datetime
today = datetime.date.today()
print('Today is: ' + today.strftime("%B %d, %Y")) # Today is: October 06, 2016

Where:

  • %B - Month as locale’s full name
  • %d - Day of the month
  • %Y - Year with century as a decimal number
uv.nikita
  • 385
  • 4
  • 9
0

Modified your program slightly using strftime(' %B %d %Y')

Working Code

import datetime
today = datetime.date.today().strftime(' %B %d %Y')

print ('Today is: ' + today)

OUTPUT:

> ================================ RESTART =========================
Today is:  October 06 2016
> 
Anil_M
  • 9,810
  • 6
  • 40
  • 67
0
import datetime
today = datetime.date.today()

print ('Today is: ' + today.strftime("%B %d , %Y"))
Ritesh Khichadia
  • 846
  • 7
  • 20
  • While this code snippet may answer the question, it doesn't provide any context to explain how or why. Consider adding a sentence or two to explain your answer. – brandonscript Oct 07 '16 at 03:25