We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

set_localized_time notices

Developer Preview

Dom Stubbs's avatar
Dom Stubbs
156 posts
12 years ago
Dom Stubbs's avatar Dom Stubbs

I appreciate that set_localized_time is deprecated but I’m assuming that the pre-2.6 behaviour should still work for the time being. With a mostly vanilla 2.6 install I’m seeing the following when I call set_localized_time(timestamp).

Severity: Notice Message: Undefined index: Europe/London Filename: libraries/Localize.php Line Number: 720

It looks as though the deprecation notice is incomplete as well:

Deprecated function set_localized_time() called in /blah/blah.php on line 230. Deprecated since 2.6. Use instead.

I take it that $use_instead should be format_date()?

If it makes any difference I’m using the second preview build.

       
Kevin Cupp's avatar
Kevin Cupp
791 posts
12 years ago
Kevin Cupp's avatar Kevin Cupp

Hi Dom Stubbs,

Since set_localized_time() is old, it only works with the old timezone notation, which you can see in the array keys in the _get_php_timezone() function. In order to make EE 2.6 work with any timezone and do automatic DST handling, we had to switch to storing the actual timezone name which the old code isn’t written for. That said, we’d strongly discourage using set_localized_time() because of that, and also since the DST settings are no longer stored, it won’t account for that properly either. Plus, manipulating a Unix timestamp which is supposed to be in GMT to make it look like it’s in another timezone is janky, we’d rather everyone move off of it ASAP. For backwards compatibility for your addon, you may want to check the EE version and conditionally use one method or the other, or just require 2.6.

Yes I’m guessing I didn’t enter a $use_instead variable because there isn’t really a 1-to-1 match for what this method did, I think what you’re seeing is more of a developer log bug which cropped up in the latest preview, I’ll fix that.

Let us know if you have any other issues.

Kevin

       
Dom Stubbs's avatar
Dom Stubbs
156 posts
12 years ago
Dom Stubbs's avatar Dom Stubbs

Hi Kevin,

As I say, I know that the code’s deprecated (and I won’t be calling that method for 2.6+ environments), I just wanted to flag up the error in case you weren’t aware of it.

Cheers, Dom

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.