i have 2 servsers 1 in america (NY) and 1 in europe (London)
my servers are synchronzied as close as possible. now when someone from europe go to my site it use the london server and same idea for the americas.
every now and then i do maintenance on my site, therefore i redirect the traffic to the other server. becuase of the timezone difference i need to make it transparent to the user so if a person from america is redirected to the server in london (due to maintenance) i need to show to him the EDT timezone
here my issue. i have query i run from mysql with dates (one is last date logged)
i want to display it correctly so my question is
should i use mysql to transform the date or php? which one is better and faster?
thanks
Source: Tips4all, CCNA FINAL EXAM
I think the best way would be to store the last login time as an UTC-value in the DB and use PHP to convert that value to the visitor's timezone. I'd always store any timestamp data as UTC in the DB, also to avoid problems with DST and all that stuff. I think in terms of speed there is not much difference if the DB calculates the display value for you or if your PHP script does it. However since your PHP script is your presentation layer, it should take care of date formatting instead of the DB.
ReplyDelete