简体   繁体   中英

How do I convert a jQuery Date value to a long value?

I have a jQuery Date function which shows output like July 09 2012 . Now I want to change this string value to a long value like 1335363564815 , eg milliseconds. How can I do this?

This is my code for my calender:

<script type="text/javascript">
         $('#date2').jdPicker({date_format:"FF dd YYYY"}); 
</script>

I use this plugin: jquery.jdpicker.js

You can do

var milliseconds  = Date.parse($('#date2').val());

As docs says

Parses a string representation of a JavaScript date, and returns the number of milliseconds

Demo Here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM