Created
November 5, 2016 21:40
-
-
Save le717/e4f7592be65824417a93daf53ca1b777 to your computer and use it in GitHub Desktop.
ACTUAL CODE I HAD TO WRITE BECAUSE PHP'S DATE PARSING IS GFXJDNVJVXJHZGVFHDSVXFHZFHSZDBMDBGMNGDFCVNG
This file contains hidden or 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 | |
/** | |
* Convert a date to the "American" date format. | |
* | |
* While one may assume this function appropriately rearranges the | |
* date format to follow the American MM/DD/YYYY format, in reality | |
* and by intention, this function is very naive. All it does is replace | |
* all dashes and periods with a forward-slash, preserving all ordering | |
* and leaving that up to the caller. | |
* This behavior is to allow PHP to correctly parse dates in the American | |
* format, as it foolishly uses the delimiter to determine the parse format | |
* rather than using the data in the string. | |
* | |
* @see {http://php.net/manual/en/function.strtotime.php#refsect1-function.strtotime-notes|Third note box} | |
* @param {string} $date - Any acceptable date format. | |
* @returns {string} The same date format but with forward-slash deliminators. | |
*/ | |
function convertToAmericanDate($date) { | |
return str_replace(['-', '.'], '/', $date); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment