Convert date format python

前端 未结 3 2088
天涯浪人
天涯浪人 2020-12-06 07:26

I have django form and I am receiving from POST a date formated like \"%d/%m/%Y\" and I would like to convert it to \"%Y-%m-%d\", How could I do it?

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-06 08:17

    You can use easy_date to make it easy:

    import date_converter
    my_datetime = date_converter.string_to_string('02/05/2012', '%d/%m/%Y', '%Y-%m-%d')
    

提交回复
热议问题