日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

JS将日期转换为yyyy-MM-dd HH:mm:ss

發布時間:2025/4/9 58 豆豆
生活随笔 收集整理的這篇文章主要介紹了 JS将日期转换为yyyy-MM-dd HH:mm:ss 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
//格式化后日期為:yyyy-MM-dd HH:mm:ss function FormatAllDate(sDate) {var date = new Date(sDate);var seperator1 = "-";var seperator2 = ":";var month = date.getMonth() + 1;var strDate = date.getDate();var hours = date.getHours();var minutes = date.getMinutes();var seconds = date.getSeconds();//if (month >= 1 && month <= 9) {month = "0" + month;}//if (strDate >= 0 && strDate <= 9) {strDate = "0" + strDate;}//if (hours >= 0 && hours <= 9) {hours = "0" + hours;}//if (minutes >= 0 && minutes <= 9) {minutes = "0" + minutes;}//if (seconds >= 0 && seconds <= 9) {seconds = "0" + seconds;}//格式化后日期為:yyyy-MM-dd HH:mm:ssvar currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate+ " " + hours + seperator2 + minutes + seperator2 + seconds;return currentdate; }

?

轉載于:https://www.cnblogs.com/rwh871212/p/5283343.html

總結

以上是生活随笔為你收集整理的JS将日期转换为yyyy-MM-dd HH:mm:ss的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。