Skip to content

Instantly share code, notes, and snippets.

@dfwood
dfwood / wp-iso8601-datetime.php
Last active March 6, 2017 20:24
Datetime conversion functions for WordPress using the ISO8601 standard.
<?php
/**
* Why does this exist? http://xkcd.com/1179/ also because it makes sense to have a standard way in WordPress to work with
* dates and times so that plugin developers can create plugins that will work in any timezone worldwide.
*
* WordPress sets the default timezone during execution to UTC, reguardless of what the server is set to.
* This means that date( 'FORMAT' ) will always give you the current time in UTC, not the timezone you have set
* in the WP admin settings. Use date( 'FORMAT', current_time( 'timestamp' ) ) instead to get WP local time. Likewise,
* use current_time( 'timestamp' ) instead of time() for the local time.
*/
@dfwood
dfwood / CheckWPVersion.php
Last active October 14, 2015 02:07
Check for the current WP version and do stuff based on the version. Drop into a function or wherever it is needed.
<?php
global $wp_version;
if ( version_compare( $wp_version, '3.5', '>=' ) ) {
// WP Version 3.5.x+, do something!
}