-
-
Notifications
You must be signed in to change notification settings - Fork 492
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Docs: Refresh restricted datetime functions docs
Kept the descriptions for individual code comparisons simpler, and populated the <standard> element with more description instead.
- Loading branch information
Showing
2 changed files
with
44 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<documentation title="Restricted Date and Time Functions"> | ||
<standard> | ||
<![CDATA[ | ||
The restricted functions date_default_timezone_set() and date() should not be used. | ||
Using date_default_timezone_set() isn't allowed, because WordPress core needs default time zone set to UTC. Use DateTime object or WP core API functions instead. | ||
Using date() isn't allowed, as it is affected by runtime timezone changes which can cause date/time to be incorrectly displayed. Use gmdate() instead. | ||
]]> | ||
</standard> | ||
<code_comparison> | ||
<code title="Valid: Using DateTime object."> | ||
<![CDATA[ | ||
$date = new DateTime(); | ||
$date->setTimezone( | ||
new DateTimeZone( 'Europe/Amsterdam' ) | ||
); | ||
]]> | ||
</code> | ||
<code title="Invalid: Using date_default_timezone_set()."> | ||
<![CDATA[ | ||
date_default_timezone_set( 'Europe/Amsterdam' ); | ||
]]> | ||
</code> | ||
</code_comparison> | ||
<code_comparison> | ||
<code title="Valid: Using gmdate()."> | ||
<![CDATA[ | ||
$last_updated = gmdate( | ||
'Y-m-d\TH:i:s', | ||
strtotime( $plugin['last_updated'] ) | ||
); | ||
]]> | ||
</code> | ||
<code title="Invalid: Using date()."> | ||
<![CDATA[ | ||
$last_updated = date( | ||
'Y-m-d\TH:i:s', | ||
strtotime( $plugin['last_updated'] ) | ||
); | ||
]]> | ||
</code> | ||
</code_comparison> | ||
</documentation> |
This file was deleted.
Oops, something went wrong.