Source Code:
(back to article)
<?php // Get the current local time $now = time(); $localtime = localtime($now); print_r($localtime); // Get the local time for a specific Unix timestamp $timestamp = 1646563200; // March 5, 2022, 12:00:00 AM UTC $localtime = localtime($timestamp); print_r($localtime); // Get the local time as an associative array $now = time(); $localtime = localtime($now, true); echo "The current year is " . ($localtime['tm_year'] + 1900);
Result:
Report an issue