Reputation: 169
have a timezone info field that shows the timezone offset ( e.g 'UTC+1' ). used 'getOffset' for this, but now in dst time, its returning 'UTC+2' for the same timezone.
my question is how to detect if dst is enabled or how to get the dst free offset ?
checked DateTimeZone and DateTime docu but haven't found anything.
Upvotes: 0
Views: 103
Reputation: 522032
You can only get the information whether something is currently in DST or not from a Date
object; a DateTimeZone
never "is" in DST or not, it merely contains the information when a date goes into DST, so it always depends on a particular Date
instance. There's no dedicated method for that on the Date
class, but it's a possible date formatter:
echo 'Is DST: ', $date->format('I') ? 'yes' : 'no';
Upvotes: 1