Last active
August 29, 2015 14:07
-
-
Save niksudan/8d6b710d4fd6e43d516b to your computer and use it in GitHub Desktop.
Reorder date string [PHP]
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
<?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