<?php
date_default_timezone_set('Europe/Moscow');
$date=date('M d,Y H:i:s');
$time=strtotime($date);
$new_date='Nov 27,2012 20:00:00';
$new_time=strtotime($new_date);
$loc='http://'.$_SERVER['SERVER_NAME'].'/';
if(isset($_COOKIE['lang'])) {
$file=$_COOKIE['lang'];
} else {
$file='ru';
}
$lang['ru']=array(
'open'=>'До открытия:',
'days'=>'Дней:',
'hours'=>'Часов:',
'minutes'=>'Минут:',
'seconds'=>'Секунд:'
);
$lang['en']=array(
'open'=>'Open after:',
'days'=>'Days:',
'hours'=>'Hours:',
'minutes'=>'Minutes:',
'seconds'=>'Seconds:'
);
function lang($key) {
if($key) {
global $file,$lang;
return $lang[$file][$key];
}
return false;
}
?>
<script type="text/javascript">
function timer() {
var self=this,
date=new Date('<?=$date?>'),
new_date=new Date('<?=$new_date?>'),
time=(new_date.getTime()-date.getTime()),
secounds,
last_secounds,
days,
last_days,
hours,
last_hours,
minutes;
if(1<time) {
secounds=parseInt(time/1000);
days=parseInt(secounds/(24*60*60));
last_days=secounds-days*24*3600;
hours=parseInt(last_days/3600);
if(10>hours) {
hours='0'+hours;
}
last_hours=last_days-hours*3600;
minutes=(parseInt(last_hours/60));
if(10>minutes) {
minutes='0'+minutes;
}
last_secounds=last_hours-minutes*60;
if(10>last_secounds) {
last_secounds='0'+last_secounds;
}
id('days',days);
id('hours',hours);
id('minutes',minutes);
id('secounds',last_secounds);
}
}
function id(id,value) {
value=value || '';
if(value) {
return document.getElementById(id).innerHTML=value;
} else {
return document.getElementById(id);
}
}
timer();
</script>
<style type="text/css">
#timers td{color:#f9ff00;}
</style>
<table id="timers">
<tr id="timers">
<td colspan="4">
<?=lang('open')?>
</td>
</tr>
<tr id="timers">
<td>
<?=lang('days')?>
</td>
<td>
<?=lang('hours')?>
</td>
<td>
<?=lang('minutes')?>
</td>
<td>
<?=lang('seconds')?>
</td>
</tr>
<tr id="timers">
<td id="days"></td>
<td id="hours"></td>
<td id="minutes"></td>
<td id="secounds"></td>
</tr>
</table>
</div>
=)))))))
давно еще писал, не стану замарачиваться))))
Он мне не нужен)))
уже по другому давно делаю=))
Тут бы переписать)) по компактнее))