I'm using Flot for graphing and I'm having trouble getting it to report 12 hour time, instead of 24 hour time.
I'm using this code (which works fine otherwise)
$(function () {
$.plot($("#placeholder"),
[ { data: 0 } ],
{ xaxes: [ { mode: 'time',
twelveHourClock: true,
timeformat: "%H:%M%p"} ],
yaxes: [ ] })
});
Any idea why it's not respecting the %p, which should force 12hour AND the twelveHourClock is set to true ...
Thanks in advance!
You need to use %I (12 hour format) instead of %H (24 hour format). If you do this then there is also no need to set "twelveHourClock" to true. Also, %p is just for adding the 'am/pm'.
From the docs:
If you set "twelveHourClock" to true, the autogenerated timestamps will use 12 hour AM/PM timestamps instead of 24 hour. This only applies if you have not set "timeformat". Use the "%I" and "%p" or "%P" options if you want to build your own format string with 12-hour times.