GravityKit\GravityMigrate\SiteTime
Formats an instant for a reader of this site's admin.
Every date wp-admin shows -- Forms > Entries included -- is in the site's timezone, because the instants being described belong to the site rather than to whoever happens to be looking. A browser formatting the same instant renders it in the reader's zone instead, so a migration that finished at 00:33 on a site in Los Angeles reads as 17:33 to somebody in Tokyo, on a screen where every other time is the site's.
The zone is resolved here, at the moment of formatting, rather than handed to the client as an
offset to apply later. An offset captured while a page rendered is wrong for any instant on the
far side of a daylight-saving change -- and a finish time is by definition an instant that
arrives after the page rendered -- while a whole-hour offset is wrong all year on a site at
+05:45 or +09:30. \wp_date reads \wp_timezone per call, so both are right.
Since: %ver%
Source: src/SiteTime.php:27
Details
- Kind:
class - Namespace:
GravityKit\GravityMigrate
Methods
| Method | Description |
|---|---|
time() | A time of day, on the site's clock and in the format the site's operator picked. |
Method Reference
time()
public static function time( int $timestamp ): string
A time of day, on the site's clock and in the format the site's operator picked.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$timestamp | int | A Unix timestamp, as time() returns it: UTC, zoneless. |
Returns
string— The formatted time, or '' when there is no instant to describe. Empty rather than "now": a caller with nothing to say must say nothing, and the current time is the one answer that is certainly wrong.
Since: %ver%
Source: src/SiteTime.php:49