PHP和js获取指定时间倒计时

时间:2022-03-15 22:08:38
<script>
$(document).ready(function(){
   $('a[nctype="nyroModal"]').nyroModal();
   <?php
    if ($output['refund']['add_time']>0 && $output['refund']['seller_time']==0)
    {
    ?>
    setInterval(function(){ShowCountDown( "<?php echo date("Y-m-d H:i:s",strtotime("+1 week",$output['refund']['add_time']));?>",'left-time')}, 1000)
 <?php } ?>
});

function ShowCountDown(dateString,divname)
{
    var now = new Date();
    var endDate = new Date(dateString);
    var leftTime=endDate.getTime()-now.getTime();
    var leftsecond = parseInt(leftTime/1000);
//var day1=parseInt(leftsecond/(24*60*60*6));
    var day1=Math.floor(leftsecond/(60*60*24));
    var hour=Math.floor((leftsecond-day1*24*60*60)/3600);
    var minute=Math.floor((leftsecond-day1*24*60*60-hour*3600)/60);
    var second=Math.floor(leftsecond-day1*24*60*60-hour*3600-minute*60);
    var cc = document.getElementById(divname);
    cc.innerHTML = '卖家确认剩余时间:'+day1+""+hour+"小时"+minute+""+second+"";
}
</script>