最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - jQuery UI - Convert jQuery UI Datepicker to UNIX time - Stack Overflow

programmeradmin3浏览0评论

I'm using jQuery UI datepicker with time plugin. This is how I display time on the page in datepicker itself:

21.06.2012 08:00

I'd like to convert this time to UNIX timestamp before sending to backend. How can I do this? I don't need to dispay UNIX time on the page, I only need to convert before posting. I've tried:

var d = Date.parse(value_of_datepicker);

but had no luck. It seems date should be formated in another way. Also I've tried several build-in datepicker functions, but all of them set date display view. Thanks.

I'm using jQuery UI datepicker with time plugin. This is how I display time on the page in datepicker itself:

21.06.2012 08:00

I'd like to convert this time to UNIX timestamp before sending to backend. How can I do this? I don't need to dispay UNIX time on the page, I only need to convert before posting. I've tried:

var d = Date.parse(value_of_datepicker);

but had no luck. It seems date should be formated in another way. Also I've tried several build-in datepicker functions, but all of them set date display view. Thanks.

Share Improve this question asked Jun 16, 2012 at 9:35 f1nnf1nn 7,04724 gold badges71 silver badges94 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 17

If you use jQuery timepicker by Trent Richardson, you can do this: $("#your_datepicker").datetimepicker("getDate").getTime() / 1000

http://jsfiddle.net/d6Tky/

Remember that this function may return null if no date has been selected.

发布评论

评论列表(0)

  1. 暂无评论