var stsrtTime = /* здесь что-то из DB в формате int */ж
/*
Далее запуск счётчика
*/
<?php
// блаблабла
?>
<script>
var stsrtTime = <?php echo $phpStartTime; ?>;
</script>
// блаблабла
?>
<?php
require_once 'admin/connection.php';
$result = mysql_query('SELECT * FROM time WHERE 1');
$row = mysql_fetch_assoc($result);
$count = $row['time'];
?>
<script>
// Set the date we're counting down to
var countDownDate = <?php echo $count; ?>;
//var countDownDate = new Date("November 5, 2020 15:37:25").getTime();
// Update the count down every 1 second
var x = setInterval(function() {
// Get today's date and time
var now = new Date().getTime();
// Find the distance between now and the count down date
var distance = countDownDate - now;
// Time calculations for days, hours, minutes and seconds
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
// Output the result in an element with id="demo"
document.getElementById("demo").innerHTML = minutes + "m " + seconds + "s ";
// If the count down is over, write some text
if (distance < 0) {
clearInterval(x);
document.getElementById("demo").innerHTML = "EXPIRED";
}
}, 1000);
</script>
var countDownDate = <?php echo $count; ?>;
date('Y-m-d H:i:s');
<?php
require_once 'admin/connection.php';
$result = mysql_query('SELECT * FROM time WHERE 1');
$row = mysql_fetch_assoc($result);
$count = $row['time'];
echo $count;
?>
<?php
require_once 'admin/connection.php';
$result = mysql_query('SELECT * FROM time WHERE 1');
$row = mysql_fetch_assoc($result);
$date= $row['time'];//вот в этой переменной дата
//здесь нужно преобразовать дату из time в читаемый формат, так как я указал выше, если требуется
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>HTML5</title>
</head>
<body>
<div id="target"><?php echo $date ?></div>
//сам вывод
</body>
</html>
<?php
require_once 'admin/connection.php';
$result = mysql_query('SELECT * FROM time WHERE 1');
$row = mysql_fetch_assoc($result);
$date= $row['time'];
?>
<span style="font-size: 16px;"><b>Ends in:</b>  <span id="target" style="font-size: 18px;"></span></span>
<br><br>
<span style="font-size: 16px;"><b>You Save:</b>  <span style="font-size: 16px; color: #B12704;">$125.00 (25%)</span></span>
<script>
var target_date = new Date("2019-08-06").getTime(); // установить дату обратного отсчета из php
var days, hours, minutes, seconds; // переменные для единиц времени
var countdown = document.getElementById("target");
setInterval(function () { getCountdown(); }, 1000);
function getCountdown(){
var current_date = new Date().getTime();
var seconds_left = (target_date - current_date) / 1000;
days = pad( parseInt(seconds_left / 86400) );
seconds_left = seconds_left % 86400;
console.log(seconds_left);
hours = pad( parseInt(seconds_left / 3600) );
seconds_left = seconds_left % 3600;
minutes = pad( parseInt(seconds_left / 60) );
seconds = pad( parseInt( seconds_left % 60 ) );
countdown.innerHTML = "<span>д:" + days + "</span> - <span>ч:" + hours + "</span> - <span>м:" + minutes + "</span> - <span>с:" + seconds + "</span>";
}
function pad(n) {
return (n < 10 ? '0' : '') + n;
}
</script>
var target_date = new Date("2019-08-06").getTime();
var target_date = new Date("<?php echo $date?>").getTime();