Home >Backend Development >PHP Tutorial >JS怎么调用TP框架的代码{$v.}
<script> <br />function fresh() <br />{ <br /> var endtime= new Date(); <br /> var nowtime =new Date("{$v.date}"); 这里怎么调用的不对Date("{$v.date}"); <br /> <br /> var leftsecond=parseInt((endtime.getTime()-nowtime.getTime())/1000); <br /> <br /> d=parseInt(leftsecond/(3600*24)); <br /> h=parseInt((leftsecond/3600)%24); <br /> m=parseInt((leftsecond/60)%60); <br /> s=parseInt(leftsecond%60); <br /> <br />document.getElementById("times").innerHTML=d+'天'+h+"小时"+m+"分"+s+"秒"; <br />setTimeout(fresh,1000); <br /> <br />} <br />window.onload=fresh; <br /></script>
.........
{$v.date} 这个是从后台传过来的吧?可以这样$this->assign("date",time());
然后在js里 var time="{$date}"
这个time就是传过来的当前时间