I’ve actual date from php script
$time_local_js = date('Y,m,d,H,i', strtotime('now'));
and I must to transfer it into js script
<span id="odliczanie"></span>
<script type="text/javascript">
d_new=+new Date(2012,11,6,21,00,00);
d_old=new Date();
(function(){
sec=(d_new-d_old)/1000;
document.getElementById('odliczanie').innerHTML=~~(sec/(3600*24))+' days '+~~(sec/3600)%24+' hours '+~~(sec/60)%60+' min '+~~sec%60+' sek';
setTimeout(arguments.callee,1000)})()
</script>
into the variable ‘d_old’ (now it’s temporarily new Date()). How to do it?
I’m assuming you’re outputting the file the includes the js with a php script. If not, you’ll need to.
The old line:
The new line:
You’re outputting the time of $time_local_js directly into the JS code that creates the value of d_old.