javascript - NaN:NaN in firefox and IE ,CHROME works fine -
my script ok in chrome, in firefox , ie result is: nan:nan. script: knows whats wrong?
output of $db[time] : 2013-10-07 14:28:35 (timestamp database)
<script> var end = new date('<?=$db[time]?>'); var _second = 1000; var _minute = _second * 60; var _hour = _minute * 60; var _day = _hour * 24; var timer; function showremaining() { var = new date(); var distance = end - now; if (distance < 0) { clearinterval(timer); document.getelementbyid('countdown').innerhtml = 'its time!</font><br><br>'; return; } var days = math.floor(distance / _day); var hours = math.floor((distance % _day) / _hour); var minutes = math.floor((distance % _hour) / _minute); var seconds = math.floor((distance % _minute) / _second); document.getelementbyid('countdown').innerhtml = '<font color="orange">' + minutes + ':'; document.getelementbyid('countdown').innerhtml += '<font color="orange">' + seconds + ' minutes</font>'; } timer = setinterval(showremaining, 1000); </script>
this because of value of $db[time]
.
you said in comment format of date/time 2013-10-07 14:28:35
default datetime output mysql, when needs 2013-10-07t14:28:35
.
chrome supports 2013-10-07 14:28:35
format convenience it's not in javascript spec, not other browsers do.
try this:
<? echo str_replace(' ', 't', $db['time']); ?>
Comments
Post a Comment