Created
September 25, 2012 14:05
-
-
Save ianlandsman/3782120 to your computer and use it in GitHub Desktop.
Windows strftime Hack
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
function strftime_win32($format, $ts = null) { | |
if (!$ts) $ts = time(); | |
$mapping = array( | |
'%C' => sprintf("%02d", date("Y", $ts) / 100), | |
'%D' => '%m/%d/%y', | |
'%e' => sprintf("%' 2d", date("j", $ts)), | |
'%h' => '%b', | |
'%n' => "\n", | |
'%r' => date("h:i:s", $ts) . " %p", | |
'%R' => date("H:i", $ts), | |
'%t' => "\t", | |
'%T' => '%H:%M:%S', | |
'%u' => ($w = date("w", $ts)) ? $w : 7 | |
); | |
$format = str_replace( | |
array_keys($mapping), | |
array_values($mapping), | |
$format | |
); | |
return strftime($format, $ts); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment