python - Representing Date as numeric number -
so i'm trying figure out way convert normal date in format "dd/mm/yyyy" (for example : 31/12/2016).
i want find way convert date unique number, can re-convert back.
for example thought of sum=day+month*12 + year*365
number , :
(sum % 365 ) / 12...
but it's not working each statment. ideas?
it far better not handle strings yourself. instead use module called datetime. here incredibly answer should satisfy need do. converting string datetime
for example, in case need following
import datetime your_date = datetime.datetime.strptime("31/12/2016", "%d/%m/%y")
then article how convert datetime integer in python explains how can turn integer, stated in answer, bad idea.
Comments
Post a Comment