Question

I'm using DateBox as a time picker control in my web application, and it works, but I'm having some trouble with formatting the time output.

The documentation on the site is pretty complete... or so it seems. It's as if some of the settings don't work at all.

I've tried using the timeOutput option to format the output string, but that doesn't seem to work at all.

Does anybody have experience using the DateBox plugin? Could I get some advice on formatting the time output string?

Here's the code I use to set up the TimeBox control:

$("input[type=time]").datebox({
    mode: "timebox",
    zindex: 2100,
    useNewStyle: true,
    centerHoriz: true,
    centerVert: true,
    useClearButton: true,
    overrideTimeFormat: 12
});

Thanks in advance.

Was it helpful?

Solution

The problem lies partially in my negligence and partially in the documentation's organization.

At the very bottom of this page, there's a section labeled "Internationalization/Localization," where the option I've been trying to use, timeOutput, is located.

What I didn't notice is that at the top of the list of options, there's a note that reads:

NOTE:: To override, use overrideNameOfOption - e.g. overrideTimeFormat

So, that said, it turns out that you do have to override the timeOutput option by setting it as follows:

$("input[type=time]").datebox({
    mode: "timebox",
    zindex: 2100,
    useNewStyle: true,
    centerHoriz: true,
    centerVert: true,
    useClearButton: true,
    overrideTimeFormat: 12,
    overrideTimeOutput: "%l:%M %p"
});

OTHER TIPS

Thanks for digging into this, I had the exact same problem.

Another pointer -- make sure to use camelcase as the author describes here, in the "reminder about overrides."

e.g. -- "overrideTimeOutput" works, but "overrideTimeoutput" doesn't.

I agree, this is a very cool little plugin. I'm perhaps a bit more lenient regarding the documentation -- while it takes some digging to figure things out, I've learned a lot from it (including the pointer above).

I also appreciate the author's presence in these and other forums -- that has helped tremendously too. I wish he/she would make registering on his/her site easier -- I tried about fifteen times, kept getting inexplicable error messages, and gave up.

But that's a quibble. Long live the community!!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top