Keith Count down with server time

Keith jQuery Count down time working with server time with Ajax


Javascript  code

<script>
function serverTime() {
var time = null;
$.ajax({url: 'serverTime.php',
async: false, dataType: 'text',
success: function(text) {
time = new Date(text);
}, error: function(http, message, exc) {
time = new Date();
}});
return time;
}

$(document).ready(function () {



$('#120').countdown({
until: new Date(2014, 03 - 1, 30),
format: 'DHMS',
serverSync: serverTime
});
});
</script>
 
PHP file

<?php
$now = new DateTime(null, new DateTimeZone('Asia/Kolkata'));
echo $now->format("M j, Y H:i:s O")."\n";
?>