The PHP Function Gmdate Formats a GMT/UTC Date and Time
The php function gmdate formats a GMT/UTC date and time. It takes an integer Unix timestamp and formatters it to a human-readable string. There are 35 pre-defined formatting strings to choose from.
Unlike the date() function which uses the server's local timezone, gmdate() sets its own default time zone so that all date and time calculations use the same standardised international GMT. This can be useful when you need to work with dates from many different locations, for example when calculating time elapsed between two locations.
When using gmdate() it is important to remember that it is not accurate for dates more than one month apart as it relies on a convention of weeks which do not correspond with months (e.g. 28 days). Similarly, it is not accurate for storing user timezones in the database since some users may be on daylight saving time which changes their offset by an hour.
For these reasons, it is preferable to use a more accurate and flexible function like rel_time() which accepts two parameters, an int representing epoch seconds and a format string. This will return the timestamp with it's correct daylight savings adjustment applied. In addition, it accepts formats that are supported by strtotime(). Both of these functions are available in the PHP manual's Time Functions section. As of PHP 8.1, the functions strftime() and gmstrftime() have been deprecated and will emit an E_WARNING if they are used. Instead, PHP now offers a better locale-independent and locale-aware date/time formatting API called IntlDateFormatter::format (requires the Intl extension).