Is there a function in python that will return date in a string format : i.e 30/11/2015 will be returned as 30th November 2015 ? If the inputs was d=30,m=11,y=2015
Thanks for any help!
Is there a function in python that will return date in a string format : i.e 30/11/2015 will be returned as 30th November 2015 ? If the inputs was d=30,m=11,y=2015
Thanks for any help!
check datetime
generally you can do something like this:
import datetime
def special_datetime(d, m, y):
s = datetime.datetime(day=d,month=m,year=y).strftime('%d.%B %Y')
(d, my) = s.split('.')
if int(d)%10 == 1:
d += 'st '
elif int(d) % 10 == 2:
d += 'nd '
elif int(d) % 10 == 3:
d += 'rd '
else:
d += 'th '
return d + my
The strftime behavior is described in the same documentation at the end