时间格式化
最编程
2024-08-03 20:42:05
...
第一种
function formatDate(time){
var date = new Date(time);
var year = date.getFullYear(),
month = date.getMonth() + 1,//月份是从0开始的
day = date.getDate(),
hour = date.getHours(),
min = date.getMinutes(),
sec = date.getSeconds();
var newTime = year + '-' +
month + '-' +
day + ' ' +
hour + ':' +
min + ':' +
sec;
return newTime;
}
输出结果:
上一篇: 如何用moment库来美化你的日期显示?
下一篇: JavaScript 时间戳格式化技巧
推荐阅读
-
vue 通过元素用户界面的 el-date-picker 报告页眉时间,其中包括开始时间和结束时间
-
元素将时间和日期框设置为早于当前时间和日期,以禁用
-
时间序列预测 (VI) - 循环神经网络 (RNN)
-
to_sql报错 在字符串格式化过程中未转换所有参数
-
消除奇怪的前端错误:1 比特损失导致音频/视频播放时间无限增长 - Http 分路传输的核心分析和坑洞 - 调试程序
-
长时间佩戴华为 FreeBuds 6i 会使耳朵肿胀吗?我该怎么办?
-
Whisper 转录性能主流显卡和 CPU 的 RTF 转录时间估算
-
如何设置 GitLab 密码过期时间?
-
三天时间相隔半小时
-
不同时间的 USB 端口