Created
August 3, 2013 10:09
-
-
Save eoghanobrien/6145964 to your computer and use it in GitHub Desktop.
ExpressionEngine's Localize class currently lacks a method to modify a timestamp while keeping the member's localization settings in-tact. Adding this method around line 90 to to the file /system/expressionengine/libraries/Localize.php fixes that issue. Usage: $tomorrow = ee()->localize->modify_timestamp('+1 day');
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
| /** | |
| * Given a modification like +1 day or -2 weeks and a Unix timestamp, | |
| * returns the modified timestamp in the specified timezone or member's | |
| * current timezone. | |
| * | |
| * @param string Modificiation like +1 day | |
| * @param int Unix timestamp | |
| * @param bool Return date localized or not | |
| * @return string Formatted date | |
| */ | |
| public function modify_timestamp($modify, $timestamp = NULL, $localize = TRUE) | |
| { | |
| if ( ! ($dt = $this->_datetime($timestamp, $localize))) | |
| { | |
| return FALSE; | |
| } | |
| return $dt->modify($modify)->format('U'); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment