PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
We have different date and time functions to get server date and time but is there any way in PHP that we could display date and time of a specific place?
For example, if I want to get current date and time of Toronto, Canada. How can I do that?
Any help would be greatly appreciated.
TIA!
Joke: Some might think that first I should know about a server which is in Toronto, Canada and then I should have my site on that server.
As far as I know, there's no function that accepts 'Toronto, Canada' as arguments. I think the best you can do is use gmdate() to get the GMT time, then use strtotime() to apply the offset to get the time in Toronto (-5 I think).
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
I can calculate toronto canada time by my server time minus toronto canada's time. Is it a proper technique?
For example, my server time is
Current Server Time:9:10:53 PM (Mon)
and I know the current toronto canada time is
Monday, January 15, 2007 at 11:11:53 AM EST
and if minus 600 minutes from my server time then I get the date and time of toronto canada time.