How to Convert Date Time Between Time Zones Using PHP


Managing datetime is easy in PHP but it is really hard to manage an app that has users from different time zone. If there is any kind of email or notification system, it should be proper. When users from different time zone work on the same app, you can allow them to select their timezone but the actual processing should be on the common time of the server. So, you must know how to change the datetime from one timezone to other.

In this article, I will show you this in PHP. Before you start, you must know that PHP has built-in support for timezone and timezone change. In PHP this easy with the DateTime standard library class. You can easily change time zone of the current script, convert time and more with few lines of code.

The above code converts time from timezone Ameria/Los_Angeles to timezone UTC. you can change these values according to your own need.

To know the current timezone of the server, you can use the code given below.

I think this is an easy way of handling PHP timezones at Server Density. How you do this? Let us know in the comments.

Further reading:



Written by Deepanker

Deepanker Verma is the founder of Techlomedia. He is a tech blogger, developer and gadget freak.

Leave a Reply

Your email address will not be published. Required fields are marked *


Best Video Players for WIndows

9 Best Video Players For Windows

5 Best Screen Recorders for Ubuntu

5 Best Screen Recorders for Ubuntu