开发者

Using formatDate function of Mobiscroll jQuery Plugin

I'm sure I'm just being dim, but I can't work out how to use the formatDate utility function of the Mobiscroll date picker plugin.

The doc just says this:

formatDate function(format, date, settings) Format a date into a string value with a specified format

When the value of my input field changes I want to format the value and store it in another field, so I've attempted the following:

<inpu开发者_如何学Pythont type="text" id="startTimeInput" onChange="alert(jQuery('#startTimeInput').formatDate('yyyy-MM-dd HH:mm:ss', this.value, ''));"/>

However, the alert never fires and for some reason Firebug is playing up for me right now and as such isn't reporting anything either. Anybody got any ideas?

Note: I'm using jQuery() as I have to use jQuery.noConflict()


You should use it as:

jQuery.scroller.formatDate('yyyy-MM-dd HH:mm:ss', new Date(this.value));

Edit:

Second parameter for formatDate must be a date object, not a string.

new Date(this.value) form my example may work for some date formats, but not always.

If you want to convert it first to date (and you know the format) use:

jQuery.scroller.formatDate('yyyy-MM-dd HH:mm:ss', jQuery.scroller.parseDate(yourInputFormat, this.value));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜