javascript - Date.parse() 无法识别 hh:mm:ss.sss
问题描述
我正在尝试callLength
使用以下函数将时间字符串转换为毫秒,但返回值为NaN
.
我哪里错了?
export const timeFunc = callLength => {
console.log(callLength); // prints "00:00:32.000"
const startingTime = Date.parse('1970-01-01T00:' + callLength + 'Z') // should print length in milliseconds?
console.log(startingTime); // prints NaN
}
解决方案
你增加了两次时间。
Date.parse('1970-01-01T00:' + "00:00:32.000" + 'Z')
推荐阅读
- geometry - Meshlab 能否判断一个点是否在网格内
- firebase - 无法从 HttpClient 传递参数,但能够从邮递员传递
- android - 以编程方式创建的可绘制对象未在 imageview 中显示
- python - 将字典值(数组)转换为列表
- azure-functions - Azure Functions - 初始化逻辑
- r - rvest html_node 返回空列表
- java - java.util.Deque 和 java.util.ArrayDeque 之间有什么区别吗
- mysql - 获取具有汇总功能的双重计数数据
- javascript - 如何在 wix 网站编辑器中使用 npm?
- php - 如何格式化包含 PHP 中不同格式的文件中的日期?