Yogesh Chauhan's Blog

How to set default timezone using PHP?

in PHP on February 25, 2021

PHP has date_default_timezone_set() function that we can use to set the default timezone.

Here’s how to use this function:


echo date_default_timezone_get();




echo date_default_timezone_get();


Be careful, when you set the timezone, it will set in all date functions used inside the page. No matter what country it is, it will be that set timezone in all date functions.

Here is the list of all supported timezones.

It will return FALSE is you don’t pass the valid timezone.

Most Read

#1 Solution to the error “Visual Studio Code can’t be opened because Apple cannot check it for malicious software” #2 How to add Read More Read Less Button using JavaScript? #3 How to check if radio button is checked or not using JavaScript? #4 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #5 PHP Login System using PDO Part 1: Create User Registration Page #6 How to uninstall Cocoapods from the Mac OS?

Recently Posted

#Apr 8 JSON.stringify() in JavaScript #Apr 7 Middleware in NextJS #Jan 17 4 advanced ways to search Colleague #Jan 16 Colleague UI Basics: The Search Area #Jan 16 Colleague UI Basics: The Context Area #Jan 16 Colleague UI Basics: Accessing the user interface
You might also like these
SQL Right JoinSQL/MySQLNumber Properties in JavaScriptJavaScriptWhat is Hoisting in JavaScript?JavaScriptWordPress 5.7 is migrating to latest jQuery version and people are freaking outjQueryHow to merge arrays in JavaScript?JavaScriptHow to Validate User Name, Email Address and URL in PHP?PHPWhat are Big Data Clusters in SQL Server?SQL/MySQLAggregate Functions Examples in Postgres for BeginnersPostgresThe Difference Between isNaN() Method And isNaN() Function In JavaScriptJavaScriptColleague UI Basics: The Search AreaColleague3 Ways we can create URLSearchParams Objects in JavaScriptJavaScriptWhat is Etrieve Flow?Miscellaneous