Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing date format after converting from int value in python

Tags:

python

Is it possible to change format of date from (YYYY,MM,DD) to (DD,MM,YYYY)..

import datetime    
date_value = 41381.0    
date_conv= datetime.date(1900, 1, 1) + datetime.timedelta(int(date_value))    
print date_conv

output:

date_conv = 2013-04-19

Converting date formats python - Unusual date formats - Extract %Y%M%D

current output is in (YYYY,MM,DD) formate.

like image 953
Deepak Dubey Avatar asked Apr 30 '13 12:04

Deepak Dubey


2 Answers

print date_conv.strftime('%d.%m.%Y')

prints the date in DD.MM.YYYY format. More formatting options here.

like image 99
eumiro Avatar answered Sep 30 '22 06:09

eumiro


>>> import datetime
>>> date_value = 41381.0
>>> date_conv= datetime.date(1900, 1, 1) + datetime.timedelta(int(date_value))
>>> print date_conv.strftime('%d-%m-%Y')
19-04-2013
like image 35
jamylak Avatar answered Sep 30 '22 06:09

jamylak