139k views
4 votes
Write a function called convert_format which converts the format of a date from mm/dd/yyyy to month name dd, yyyy.

User Pesla
by
5.3k points

1 Answer

3 votes

Answer:

The code is given using Python

Step-by-step explanation:

#datetime to be import

from datetime import datetime

#function convert_format to convert_format date to particular format

def convert_format():

#take date from user input

inputDate = input('Enter a date(mm/dd/yyyy): ')

#using datetime convert to format month day year

dateObject = datetime.strptime(inputDate, '%m/%d/%Y')

#print the date

print(dateObject.strftime('%B %d, %Y'))

#function call

convert_format()

User Loke
by
5.3k points