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 How to uninstall Cocoapods from the Mac OS? #6 PHP Login System using PDO Part 1: Create User Registration Page

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
The basics of @import rule in SCSS (Sass)SCSSHow to create a for loop in SCSS (Sass)?SCSSHow to add a Line Chart in Angular App?AngularMIN, MAX, COUNT, AVG and SUM in SQLSQL/MySQLHow to load variables, functions, and mixins from another module in SCSS?SCSSWhat is a “promise” in JavaScript?JavaScriptHow to import a CSS file using PHP code and not HTML code?PHPFETCH clause in PostgreSQLPostgresHow to implement NSNumberFormatter in Swift for currency?SwiftHTML canvas methodsHTMLHow to Secure Web or Mobile Browsers?MiscellaneousWhat’s the difference between a Framework and a Library?Miscellaneous