javascript - 在javascript中格式化日期直到毫秒

标签 javascript jquery microsoft-ajax

我们正在使用 Microsoft 的以下 js 库 https://ajax.aspnetcdn.com/ajax/4.0/1/MicrosoftAjax.js

var datetimehigh = new Date(2011,01,12,14,45,55,596);

var sDate =  datetimehigh.format("dd/MM/yyyy HH:mm:ss sss");

我无法让毫秒部分工作。请注意该格式来自 Microsoft 的 Mvc Ajax 库。

最佳答案

如果您使用 native Date javascript对象,你可以简单地使用.toISOString获取带毫秒的格式化字符串的方法:

const date = new Date();
const dateString = date.toISOString(); // "2020-01-06T19:57:12.146Z"

请注意,使用 .toString不会给你毫秒精度。

关于javascript - 在javascript中格式化日期直到毫秒,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9212889/

相关文章:

asp.net - Microsoft Ajax 中的假 __EVENTVALIDATION

javascript - Autoscroll 不会停止滚动 .js/jquery/ajax 问题

javascript - 在单个网页中运行多个网页

javascript - JQuery 滚动事件不起作用

javascript - 集成 VIN 解码器 API

javascript - 当命名空间已存在时,Type.registerNamespace 会抛出错误

jquery - 当 iframe 的父窗口滚动时,帮助我在 iframe 中重新居中 ModalPopup

javascript - meteor 收集.allow

javascript - 切换类搞乱了一些东西

javascript - Twig-Template 中的数据表中的静态子行(附加信息)