Ecommerce software home
Shopping Cart Software Forum for Ecommerce Templates
 
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

Find us on Facebook Follow us on Twitter View our YouTube channel
Search our site
 All Forums
 Technical
 Advanced Tips and Tricks - NO QUESTIONS PLEASE
 Absolute BEST way to set Default TIMEZONE for PHP
Author « Topic »  

ITZAP
Ecommerce Template Guru

Australia
1010 Posts

Posted - 02/22/2024 :  18:49:50  
If you Google search for "set default timezone php" you will find various suggestions that involves creating and uploading a "php.ini" file. Otherwise, add a line of code to your "includes.php" settings config file like this:

date_default_timezone_set('Australia/Sydney');

I found neither method would override the server host "php.ini" file anyway.

So here is without doubt the easiest and best way to set your "Default Timezone" for the PHP version of Ecommerce Templates:

Open your .htaccess file and, up top, add this single line of code:

php_value date.timezone 'Australia/Sydney'

The full list of PHP Supported Timezones can be found here =>
Replace the text 'Australia/Sydney' with your local Timezone.

Then upload your amended .htaccess file to the server. Done

To TEST and confirm the result:
(1) Create a file named for example: date-time.php
(2) Here is the simple HTML code for that webpage:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Server Date and Time</title>
</head>
<body>
<?php
echo "The default timezone is " . date_default_timezone_get();
echo " and the server date and time is " . date('l jS \of F Y h:i:s A');
?>
</body>
</html>

(3) Save the file, upload to server and run that date-time.php webpage in your browser.

As for the ASP version of Ecommerce Templates, perhaps somebody else may be able to help

Regards, Gary

Edited by - ITZAP on 02/22/2024 19:03:03

Phil
ECT Moderator

United Kingdom
7622 Posts

Posted - 02/23/2024 :  12:13:34  
Hi Gary,
Thanks for posting that, that does function on most servers but not all servers.

There is a lesser known method available on shared servers within later versions of the host cpanel, by going to 'Select PHP Version > Options' where the time zone can be set which actually edits the php.ini file on the server





*Contact Us*
*Buy The PHP Capture Card Plugin*
*Rate Our Services/View Our Feedback*

Edited by - Phil on 02/23/2024 12:17:01

ITZAP
Ecommerce Template Guru

Australia
1010 Posts

Posted - 02/23/2024 :  17:19:56  
Ohh WoW Phil. Entering the default timezone in cPanel, PHP Options is an even better method.

I have cPanel v110.0.23 and am also running PHP Version 8.2.
But I look at the PHP Selector Options available to edit and that "date.timezone" field is not there.

I will ask my webhost if that field can be added. But, if not, then the .htaccess file "php_value date.timezone" entry works for me.

Gary

Edited by - ITZAP on 02/23/2024 17:27:48

ITZAP
Ecommerce Template Guru

Australia
1010 Posts

Posted - 02/23/2024 :  22:26:35  
Upon enquiring, my webhost enabled the editable "date.timezone" field in PHP Selector Options on my hosting server.
That's great. Costs nothing to ask. Thanks for the heads up Phil.

Gary

Phil
ECT Moderator

United Kingdom
7622 Posts

Posted - 02/24/2024 :  02:38:20  
Hi Gary,
To be perfectly honest I stumbled upon this on a clients hosting when looking to increase the post max size and memory limit for a Wordpress site, and just happened to to see it

quote:
my webhost enabled the editable "date.timezone" field in PHP Selector Options on my hosting server.


I often wonder why they disable features like that but it's good that they enabled it for you



*Contact Us*
*Buy The PHP Capture Card Plugin*
*Rate Our Services/View Our Feedback*
  « Topic »  
Jump To:
Shopping Cart Software Forum for Ecommerce Templates © 2002-2022 ecommercetemplates.com
This page was generated in 0.01 seconds. Snitz Forums 2000