Tag Info

New answers tagged


I'm not sure why EliasNS' answer is marked correct, as far as I'm aware (and from the documentation), the second parameter of DateTime::__construct(), if provided, should be a DateTimeZone instance. The problem then becomes, how we do we create a DateTimeZone instance. This is easy if the user has selected a city as their timezone, but we can work around it ...


DateTime aceppts a DateTimeZone parameter, that you can get from WordPress options. Something like: $time = new DateTime(NULL, get_option('gmt_offset')); DateTime WordPress TimeZone Hope this helps. Edit: I'm testing it and I get an error. I don't know how to convert the timezone string to a DateTimeZone object, but that is the way.

Top 50 recent answers are included