1. Go to this page and download the library: Download alex-no/server-time-clock library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
alex-no / server-time-clock example snippets
use ServerTimeClock\ServerClock;
$clock = new ServerClock([
'client' => 'WorldTimeApi', // or 'IpGeoLocation', 'TimeApiIo'
'credentials' => [
'IpGeoLocation' => 'your-api-key', // optional, depending on the provider
'WorldTimeApi' => 'your-api-key2',
],
'enable_cache' => true,
'cache_ttl' => 300, // seconds
'useMock' => false, // Mosk is usually used for testing.
]);
$now = $clock->now(); // instance of DateTimeImmutable
echo $now->format(DATE_ATOM);