Last active
February 11, 2016 20:13
-
-
Save maxflex/0c1b1f3413e5d49ed699 to your computer and use it in GitHub Desktop.
Here
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 formatDate($date) { | |
$date = preg_replace('/:|T|\.|\+/', '-', $date); | |
$p = explode('-', $date); | |
foreach ($p as $index => &$part) { | |
if ($index == 6) { | |
$part .= str_repeat('0', 7 - strlen($part)); | |
} else { | |
$part = strlen($part) < 2 ? 0 . $part : $part; | |
} | |
} | |
return "$p[0]-$p[1]-$p[2]T$p[3]:$p[4]:$p[5].$p[6]+$p[7]:$p[8]"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment