Whats the correct format for django dateTime?

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:

2012-09-04 06:00 PM

and django throws and error saying:

[u"'2012-09-04 06:00 PM' value has an invalid format. It must be in YYYY-MM-DD HH:MM[:ss[.uuuuuu]][TZ] format."]

Ive also tried

2012-09-04 06:00PM
2012-09-04 06:00 P.M.
2012-09-04 06:00P.M.

but no luck. Can anyone see what Im doing here? Or know what django is looking for (in English)?


As said by the error msg, it expects YYYY-MM-DD HH:MM[:ss[.uuuuuu]][TZ], thus following are valid values:

2012-09-04 06:00
2012-09-04 06:00:00
2012-09-04 06:00:00.000000

# w/ optional TZ as timezone. 
2012-09-04 06:00Z # utc
2012-09-04 06:00:00+0800
2012-09-04 06:00:00.000000-08:00

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

I used this'2012-09-04 06:00:00.000000-08:00' and it worked perfectly

Need Your Help

Making JavaDocs available with GitHub, Sonatype Maven repo

java open-source github javadoc

Although Github provides a nice home for Java open source projects, there are some things that are still missing compared to more mature open source hosting places. I have so far figured out that