-1

Is PHP's native date() function return Time according to DST?

Let's consider example here. Timezone set in php.ini is America/New_York.If we consider Tue, 20 Dec 2011 20:57:45 +0000 then is it display date Tue, 20 Dec 2011 15:57:45 -0500 or -0400 for DST?

Deval Shah
  • 1,094
  • 8
  • 22
  • What are you asking? You've given us a UTC date and printed it in two timezones. America/New_York respects DST. – Mike B Jan 07 '14 at 13:05
  • 3
    Don't use date() if you want to handle daylight savings; use DateTime objects and then your DateTimeZone object has a getTransitions() method that will even tell you when the changes take place – Mark Baker Jan 07 '14 at 13:06
  • Why don't you just try? – Glavić Jan 07 '14 at 13:06
  • I recommend using `DateTime` (and `DateTimeZone`) objects too. – Martin Bean Jan 07 '14 at 13:07
  • Basically project is already implemented using `date` function and changes to be taken out so I ask this – Deval Shah Jan 07 '14 at 13:36
  • @MikeB I am asking for `date()` consider `DST` or not ? – Deval Shah Jan 07 '14 at 13:40
  • @DevalShah Yes? You know this because you compared date() output with America/New_York with vs Etc/GMT-4. Change your computers date and suddenly America/New_York matches up with Etc/GMT-5. The manual page on date() goes over all this in great detail. – Mike B Jan 07 '14 at 14:11
  • 1
    @MikeB: `Etc/GMT-x` is reverse `GMT-x`. So `Etc/GMT-4` is `GMT+4` and vice versa. – Glavić Jan 07 '14 at 15:12

1 Answers1

0

If your timezone is correctly set (see: http://php.net/manual/en/function.date-default-timezone-set.php) then it will account for DST.

Ryan
  • 3,552
  • 1
  • 22
  • 39