Thursday, August 13, 2015

jQuery- time clock singapre

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<?php date_default_timezone_set( 'Asia/Singapore' ) ;?>
<script>
<?php $year =  date("Y"); ?>
<?php $month = date("m"); ?>
<?php $day = date("d"); ?>
<?php $hour = date("H"); ?>
<?php $minute = date("i"); ?>
<?php $second = date("s"); ?>
var d = new Date('<?php echo $year;?>', '<?php echo $month;?>', '<?php echo $day;?>', '<?php echo $hour;?>', '<?php echo $minute; ?>', '<?php echo $second; ?>') ;
setInterval(function() {
        d.setSeconds(d.getSeconds() + 1);
        //jQuery('#singapore_time').text((d.getHours() +':' + d.getMinutes() + ':' + d.getSeconds() ));
        jQuery('#singapore_time').text(d.toLocaleTimeString());
    }, 1000);

</script>

<div id="singapore_time"></div>

No comments :

Post a Comment