我以 24 小時(shí)格式從我的數(shù)據(jù)庫(kù)發(fā)送數(shù)據(jù),但是當(dāng)我在前端使用它作為時(shí)間計(jì)數(shù)器時(shí),輸出給出“無(wú)”。此外,當(dāng)我打印“plan_deactive_date”時(shí),它以 12 小時(shí)格式顯示時(shí)間。那么,有沒(méi)有辦法將日期時(shí)間從 12 小時(shí)格式轉(zhuǎn)換為 24 小時(shí)格式?<script>// Set the date we're counting down tovar countDownDate = new Date("{{plan_deactive_date}}").getTime();// Update the count down every 1 secondvar x = setInterval(function() { // Get today's date and time var now = new Date().getTime(); // Find the distance between now and the count down date var distance = countDownDate - now; // Time calculations for days, hours, minutes and seconds var days = Math.floor(distance / (1000 * 60 * 60 * 24)); var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); var seconds = Math.floor((distance % (1000 * 60)) / 1000); // Display the result in the element with id="demo" document.getElementById("demo").innerHTML = days + "d " + hours + "h " + minutes + "m " + seconds + "s "; // If the count down is finished, write some text if (distance < 0) { clearInterval(x); document.getElementById("demo").innerHTML = "Expired"; }}, 1000);</script>
如何使用 java 腳本將 12 小時(shí)日期時(shí)間格式轉(zhuǎn)換為 24 小時(shí)格式?
慕運(yùn)維8079593
2021-12-02 14:51:06