PHP "get current time" and "touch()" problems
Posted: Wed Sep 10, 2008 11:15 am
I'm in the UK and my site is hosted by British Telecom. It is reliant on recording the date and time when files are uploaded by users (there's a deadline every month). To do this I use the "touch" function - (i only started using PHP three days ago so I'm still fumbling a bit).
I was puzzled by why all my file timestamps were showing five hours EARLY. On contacting BT it turns out that the hosting is provided by a Canadian company - hence the server shows Canadian time.
Of course, I could simply add five hours to the time, but I want to make sure that the time remains correct taking into consideration local UK daylight savings time changes (which are coming in the next couple of months).
Is there any way of getting the correct UK time in PHP, even though my site is hosted on a Canadian server?
thanks
Guy
edit:
So I just added five hours to the current time before "touching" the file, only to find it's now 4hrs ahead of what I wanted it to be!
I add 2hrs (2*60*60)secs instead, and it's right (well right as in Canadian time plus two hours)
I add 4hrs (4*60*60)secs and it's now 3hrs ahead (Canadian time plus eight hours)
Back to adding 5hrs (5*60*60)secs and it's back to Canadian time plus NINE hours. I need Canadian time plus FIVE hours.
See code below:
thanks for any help.
Guy
I was puzzled by why all my file timestamps were showing five hours EARLY. On contacting BT it turns out that the hosting is provided by a Canadian company - hence the server shows Canadian time.
Of course, I could simply add five hours to the time, but I want to make sure that the time remains correct taking into consideration local UK daylight savings time changes (which are coming in the next couple of months).
Is there any way of getting the correct UK time in PHP, even though my site is hosted on a Canadian server?
thanks
Guy
edit:
So I just added five hours to the current time before "touching" the file, only to find it's now 4hrs ahead of what I wanted it to be!
I add 2hrs (2*60*60)secs instead, and it's right (well right as in Canadian time plus two hours)
I add 4hrs (4*60*60)secs and it's now 3hrs ahead (Canadian time plus eight hours)
Back to adding 5hrs (5*60*60)secs and it's back to Canadian time plus NINE hours. I need Canadian time plus FIVE hours.
See code below:
Code: Select all
$time = time()+(5*60*60);
touch($imagefilename,$time);Guy