Created
July 18, 2013 07:18
-
-
Save Sleavely/6027328 to your computer and use it in GitHub Desktop.
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 | |
function correctYYMMDD($input){ | |
$input = substr($input, 0, 6); | |
//is it already in correct format? | |
if(preg_match('/[0-9][0-9](1[0-2]|0[1-9])([0-2][0-9]|3[01])/', $input)) return $input; | |
//let's reverse it. | |
$rev = array(); | |
$rev['yy'] = substr($input, 4, 2); | |
$rev['mm'] = substr($input, 2, 2); | |
$rev['dd'] = substr($input, 0, 2); | |
return $rev['yy'].$rev['mm'].$rev['dd']; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment