
如何利用javascript语法实现时间格式化,下面web建站小编给大家简单介绍一下!
获取当前时间:
let currentTime = new Date()
let endTime = `${ currentTime.getFullYear()}-${ (currentTime.getMonth() + 1) > 9 ? (currentTime.getMonth() + 1) : '0' + (currentTime.getMonth() + 1)}-${ (currentTime.getDate() + 1) > 9 ? (currentTime.getDate() + 1) : '0' + (currentTime.getDate() + 1)} 23:59:59`
获取七天前时间:
let beforeTime = new Date((new Date()).getTime() - 1000 * 60 * 60 * 24 * 7)
let startTime = `${ beforeTime.getFullYear()}-${ (beforeTime.getMonth() + 1) > 9 ? (beforeTime.getMonth() + 1) : '0' + (beforeTime.getMonth() + 1)}-${ (beforeTime.getDate() + 1) > 9 ? (beforeTime.getDate() + 1) : '0' + (beforeTime.getDate() + 1)} 00:00:00`
JavaScript动态日历:如何用变量num精准控制月份递增?
javascript语法如何把json文件输出到html页面上
javascript语法中不等于null和空字符串的3种判断方式
javascript语法读取文本文件代码(PHP代码读取文本文件)
标签: javascript语法, 格式化时间
上面是“javascript如何实现时间格式化”的全面内容,想了解更多关于 js 内容,请继续关注web建站教程。
当前网址:https://m.ipkd.cn/webs_4780.html
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

B站空降助手:一款专为哔哩哔哩(Bilibili)视频平台设计的浏览器插件
Vue.watch功能的使用及如何实现数据监听
Ola Friend:豆包推出的首款AI智能体耳机
乐拍APP最新版
阿里云盘小白羊版:一款基于阿里云盘网页版开发的PC客户端,支持win7-11,macOS,linux