UNIX booking date stored returns wrong time during BST
Posted: Wed Jun 25, 2008 1:51 am
Hi there,
A problem with my php code has developed during the switch to British Summer Time. In essence, my small business sells experience vouchers for studio recording days (http://www.giftdaze.co.uk). So for example, uncle jim buys little nephew sammy a 1 hour singing experience. Little sammy then receives his gift and calls us to book a date in the diary. My online diary stores this date as a ten digit INT (unix format created from mktime(bla bla bla)) in my MYSQL database. After the switch to BST, the dates returned are an hour ahead of what they should be, and I'm guessing they'll be right again when standard GMT switches back in again.
How could it be that you store a date as a unix time stamp, then when you recall it and use something like ECHO DATE("g.ia",$STOREDUNIX); it returns the time + 1 hour for BST - this is not good for someone who has an hour booking in the studio! They turn up as there session finishes!
perhaps I can switch off BST on the server thus keeping all the dates in one time frame?
I've obviously understood the date function wrong, and should probably store the date some other fashion I guess. I've mucked about with GMDATE a little thinking this may help the situation but it did'nt.
Any suggestions on how I should refashion my code to give me a simple, correct date, that I can still index and search through MYSQL. I'll take another look at the MYSQL to see if I'm using the wrong function or maybe find a better way to store my dates.
Regards,
Paul MIDCALF
A problem with my php code has developed during the switch to British Summer Time. In essence, my small business sells experience vouchers for studio recording days (http://www.giftdaze.co.uk). So for example, uncle jim buys little nephew sammy a 1 hour singing experience. Little sammy then receives his gift and calls us to book a date in the diary. My online diary stores this date as a ten digit INT (unix format created from mktime(bla bla bla)) in my MYSQL database. After the switch to BST, the dates returned are an hour ahead of what they should be, and I'm guessing they'll be right again when standard GMT switches back in again.
How could it be that you store a date as a unix time stamp, then when you recall it and use something like ECHO DATE("g.ia",$STOREDUNIX); it returns the time + 1 hour for BST - this is not good for someone who has an hour booking in the studio! They turn up as there session finishes!
perhaps I can switch off BST on the server thus keeping all the dates in one time frame?
I've obviously understood the date function wrong, and should probably store the date some other fashion I guess. I've mucked about with GMDATE a little thinking this may help the situation but it did'nt.
Any suggestions on how I should refashion my code to give me a simple, correct date, that I can still index and search through MYSQL. I'll take another look at the MYSQL to see if I'm using the wrong function or maybe find a better way to store my dates.
Regards,
Paul MIDCALF