Recently at work I came across an odd bug involving gmdate().
A client wanted us to post some information to them including two fields: source_date and source_time. The values are really just the time when we’re sending the information to them. However, they wanted it to be sent as GMT. So in preparing the request, I wrapped the source_time in gmdate(), tested and confirmed that it was giving the correct result.
Then during an audit of their data they pointed out that around midnight our time would swing back 24 hours. Of course the issue was not wrapping the source_date in the same function. By not doing that our time would advance to tomorrow (from our perspective) but the date would be sent as today – therefore appearing to them as 24 hours previous.
It’s an easy bug to fix, and obvious once you think about it. I think it really shows the danger of failing to imagine edge cases – always a danger when working with dates.