function computer(date){
let now=new Date()//获取当前时间戳
let future=new Date(date)//距离的时间
let index=(future-now)/1000/(60*60*24)
let day=parseInt(index)//天
let h=parseInt((index-day)*24)//时
let m=parseInt((index-day-h/24)*24*60)//分
let s=parseInt((index-day-h/24-m/60/24)*24*60*60)//秒
let str=day+"天"+h+"小时"+m+"分"+s+"秒"
return str
}
console.log(computer('1/1/2023'))
本文发布于:2024-02-02 08:00:45,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170683204442445.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |