javascript 将日期时间转换为毫秒

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12435403/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 16:11:30  来源:igfitidea点击:

convert datetime to milliseconds

javascriptasp.net-mvc

提问by WebDeveloper

i want convert a datetime variable in ASP.NET MVC to milliseconds,for example like to this:

我想将 ASP.NET MVC 中的日期时间变量转换为毫秒,例如像这样:

'1288323623006'

'1288323623006'

which '1288323623006' in javascript with this format 'yyyy-MM-dd HH:mm:ss Z' means ' 2010-10-29 07:10:23 -3.530'.

其中'1288323623006'在javascript中使用这种格式'yyyy-MM-dd HH:mm:ss Z'表示'2010-10-29 07:10:23 -3.530'。

回答by webdeveloper

In javascript getTime()return the number of milliseconds since 1970/01/01.

在 javascript 中getTime()返回自 1970/01/01 以来的毫秒数。

This link is answer for your question DateTime to javascript date

此链接是您的问题DateTime to javascript date 的答案

回答by Srinivas

var d = new Date(your date); then you can apply all the date functions on d this should help. https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date

var d = 新日期(您的日期);那么您可以在 d 上应用所有日期函数,这应该会有所帮助。 https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date

do you want to convert milliseconds to date or date to milliseconds?

您想将毫秒转换为日期还是将日期转换为毫秒?