How to Set IST in PHP

please click here for more wordpress cource

To set IST (Indian Standard Time) in PHP, you can use the date_default_timezone_set() function. Here’s an example:


This sets the default timezone to Asia/Kolkata, which is the timezone for India.

You can also use the DateTimeZone class to create a DateTimeZone object with the timezone you want, and then pass it to the DateTime constructor to create a DateTime object with the timezone set. Here’s an example:

$timezone = new DateTimeZone('Asia/Kolkata');
$date = new DateTime('now', $timezone);

This creates a DateTime object with the current date and time, and sets the timezone to Asia/Kolkata.

Note that it’s important to set the timezone correctly to ensure that your PHP application displays dates and times in the correct timezone.

You may also like...

Popular Posts

Leave a Reply

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