Last active
December 24, 2015 03:09
-
-
Save murdaugh/6735164 to your computer and use it in GitHub Desktop.
Revisions
-
murdaugh revised this gist
Sep 27, 2013 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ <?php function my_strftime($format,$time=null) { global $my_locale; //this is set in the header as either en_US or es_ES if($time == null) $time = time(); //if the time isn't passed in, then use the current timestamp -
murdaugh created this gist
Sep 27, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ function my_strftime($format,$time=null) { global $my_locale; //this is set in the header as either en_US or es_ES if($time == null) $time = time(); //if the time isn't passed in, then use the current timestamp if($my_locale == "en_US") return strftime($format,$time); //If it's american english, just format the time as requested else { //in my case, the only other option is es_ES, but this could be changed for whatever purposes you have global $es_locale_string; // we only care about day names and abbreviations and // month names and abbreviations, so let's turn those // into integers. and then get them out of the // es_locale_string which has been shared here: // https://gist.github.com/murdaugh/6734488 $format = str_replace("%a", $es_locale_string["weekday_abbrev"][strftime("%w",$time)], $format); //day abbreviation $format = str_replace("%A", $es_locale_string["weekday"][strftime("%w",$time)], $format); //day name $format = str_replace("%b", $es_locale_string["month_abbrev"][strftime("%m",$time)-1], $format); //month abbreviation (it's 1-based index - hence the subtraction) $format = str_replace("%B", $es_locale_string["month"][strftime("%m",$time)-1], $format); //month abbreviation (it's 1-based index - hence the subtraction) return strftime($format,$time); } }