Whats the correct format for django dateTime?

后端 未结 3 1083
再見小時候
再見小時候 2020-12-31 08:15

Im writting an app, and im using a datetime selector to allow users to select a date and time. After some formatting in javascript, im left with a dateTime like this:

<
3条回答
  •  借酒劲吻你
    2020-12-31 08:49

    After talking around, what I figured out is that there is no AM/PM input. I had to just check if my dateTimePicker was returning an AM or PM suffix, then call time.split(":"); to break up hours and minutes, convert the hours to int from a string, then add 12 to it to convert the time to 24 hour time instead of 12 hour time. Theirs probably an easier way to do it, but thats what worked for me.

    For example:

    2012-09-04 06:00 PM

    Needs to be

    2012-09-04 18:00

提交回复
热议问题