javascript 如何将 jQuery 日期值转换为长值?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17747794/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I convert a jQuery Date value to a long value?
提问by BlueShark
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
, e.g. milliseconds. How can I do this?
我有一个 jQuery Date 函数,它显示像July 09 2012
. 现在我想将此字符串值更改为长值1335363564815
,例如毫秒。我怎样才能做到这一点?
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
我使用这个插件: jquery.jdpicker.js
回答by Suresh Atta
You can do
你可以做
var milliseconds = Date.parse($('#date2').val());
Parses a string representation of a JavaScript date, and returns the number of milliseconds
解析 JavaScript 日期的字符串表示,并返回毫秒数