Skip to content

Instantly share code, notes, and snippets.

@niksudan
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niksudan/8d6b710d4fd6e43d516b to your computer and use it in GitHub Desktop.
Save niksudan/8d6b710d4fd6e43d516b to your computer and use it in GitHub Desktop.
Reorder date string [PHP]
<?php
/**
* Reorder date string
*
* @param string $input
* @param string $currentFormat
* @param string $newFormat
* @return string
*/
function reorder_date( $input, $currentFormat, $newFormat )
{
// PHP Date Format Guide - http://php.net/manual/en/function.date.php
return DateTime::createFromFormat( $currentFormat, $input )->format( $newFormat );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment