Example 1 — Legacy Call with a Safe Fallback
Check that the function exists before calling it. When it is missing, fall back to gmdate() so both paths print the same text.
<?php
error_reporting(E_ALL & ~E_DEPRECATED);
$ts = 1700000000;
if (function_exists('gmstrftime')) {
echo gmstrftime('%A, %d %B %Y', $ts), PHP_EOL;
echo gmstrftime('%H:%M:%S', $ts), PHP_EOL;
} else {
echo gmdate('l, d F Y', $ts), PHP_EOL;
echo gmdate('H:i:s', $ts), PHP_EOL;
} How It Works
- error_reporting() hides the deprecation notice on PHP 8. 1 to 8.3.
- function_exists() prevents a fatal error on versions where the function was removed.
- %A, %d, %B and %Y match l, d, F and Y in gmdate().
- %H:%M:%S matches H:i:s. Note that %M is minutes, but the date() letter for minutes is i.

