I have a server which is set to EST, and all records in the database are set to EST. I would like to know how to set it to GMT. I want to offer a time zone option to my users.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No matter in which GMT time zone the server is, here is an extremely easy way to get time and date for any time zone. This is done with the
time()andgmdate()functions. Thegmdate()function normally gives us GMT time, but by doing a trick with thetime()function we can get GMT+N or GMT-N, meaning we can get the time for any GMT time zone.For example, if you have to get the time for GMT+5, you can do it as follows
Now if you have to get the time for GMT-5, you can just subtract the offset from the
time()instead of adding to it, like in the following example where we are getting the time for GMT-4