PHP Live Clock with JQUERY

Buat File jam.php

<?php
    date_default_timezone_set('Asia/Jakarta'); // atau timezone lain
    echo $timestamp = date('H:i:s');

Tambahkan script js di bagian bawah halaman,

$(document).ready(function() {
    setInterval(timestamp, 1000);
});

function timestamp() {
    $.ajax({
        url: 'http://localhost/jam.php',
        success: function(data) {
            $('#timestamp').html(data);
        },
    });
}

Untuk menampilkan, tambahkan tag <div> seperti di bawah ini

<div id="timestamp"></div>

Enable PHP 5.6 CURL Extension Ubuntu Server 14.04 LTS

Source: https://stackoverflow.com/questions/38800606/how-to-install-php-curl-in-ubuntu-16-04

In Ubuntu 16.04 default PHP version is 7.0, if you want to use different version then you need to install PHP package according to PHP version:

  • PHP 7.2: sudo apt-get install php7.2-curl
  • PHP 7.1: sudo apt-get install php7.1-curl
  • PHP 7.0: sudo apt-get install php7.0-curl
  • PHP 5.6: sudo apt-get install php5.6-curl
  • PHP 5.5: sudo apt-get install php5.5-curl