Skip to content

Instantly share code, notes, and snippets.

@aahan
Last active December 25, 2015 22:49
Show Gist options
  • Select an option

  • Save aahan/7053035 to your computer and use it in GitHub Desktop.

Select an option

Save aahan/7053035 to your computer and use it in GitHub Desktop.
Convert date to a different format.
<?php
/*
* Always input date in ISO 8601 format (YYYY-MM-DDThh:mm:ss.sTZD) to
* allow for conversion to a different format before display.
*
* e.g. 1997-07-16T19:20:30.45+01:00, 1997-07-16
*
* http://www.w3.org/TR/NOTE-datetime
* http://php.net/manual/en/function.date.php
* http://stackoverflow.com/a/5074579
*/
$input_timestamp = strtotime( '1997-07-16' );
$new_date_format = date( 'F j, Y', $timestamp );
// Displays '1997-07-16' as 'July 16, 1997'
echo $new_date_format;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment