I found the problem. I had changed date($d) to time($d) because date($d) does not account for daylight saving time.
I have just changed it back to date($d). Now, unfortunately, the problem of the daylight saving time is back again. The site now shows the time to be an hour earlier than it actually is.