Forums / All Other Contributions/Addons / Time Zone Fix Support Thread

Time Zone Fix Support Thread

Started by gilby on 14 Feb 2011, 11:46 AM · Views: 28,393

Results 61 to 80 of 83
14 May 2013, 10:32 PM
#61
yoshi_m avatar

yoshi_m

New Zenner

Join Date:
Jan 2013
Posts:
9
Plugin Contributions:
0

Time Zone Fix Support Thread

gilby:

Not quite. See post 52
You need to include the same file in 2 places (edited for your time zone)

One for the ADMIN
YOUR_RENAMED_ADMIN\extra_configures\time_zone_fix.php

and one for the CATALOG (Store Front)
includes\extra_configures\time_zone_fix.php

I have officially been zenned.

Thank you X 10000000....

I had initially changed my timezone in php.ini, and that fixed my timezone issues only in my admin area but kept giving me wrong time stamps on orders.

Next I added the recommended timezonefix file to includes/extraconfigurations and that fixed my order time stamp, but my order update times where still messing up and I really did not know what to do.

After reading your comment just now, I uploaded the file also to myadmin/includes/extraconfigurations and voia! It works, my order update times are now correct.

Thanks you guys for sharing the knowledge.

3 Oct 2013, 4:30 PM
#62
carlvt88 avatar

carlvt88

Zen Follower

Join Date:
Aug 2007
Location:
Williston, Vermont
Posts:
180
Plugin Contributions:
0

Re: Time Zone Fix Support Thread

Zencart 1.5.1 - since the plugin only goes to 1.3.9, I started to manually make the changes. I see in the query factory on 1.5.1, the following:

        if (getenv('TZ') && !defined('DISABLE_MYSQL_TZ_SET')) @mysql_query("SET time_zone = '" . substr_replace(date("O"),":",-2,0) . "'", $this->link);

But, I don't see where the TZ environment variable is set.

I already set the timezone for PHP 5.2 using the php.ini file.

Is there a recommended way to set the TZ variable through zencart, or should I simply copy over the time_zone_fix.php files from your 1.3.9 plugin?

3 Oct 2013, 8:09 PM
#63
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

Re: Time Zone Fix Support Thread

carlvt88:

Zencart 1.5.1 - since the plugin only goes to 1.3.9, I started to manually make the changes. I see in the query factory on 1.5.1, the following:

    if (getenv('TZ') && !defined('DISABLE_MYSQL_TZ_SET')) @mysql_query("SET time_zone = '" . substr_replace(date("O"),":",-2,0) . "'", $this->link);
> But, I don't see where the TZ environment variable is set.
> 
> I already set the timezone for PHP 5.2 using the php.ini file. 
> 
> Is there a recommended way to set the TZ variable through zencart, or should I simply copy over the time_zone_fix.php files from your 1.3.9 plugin?
Starting with Zen Cart v1.5.0, this plugin's operation is part of the core-code.  You just need to create a file named time_zone_offset.php and place this file (same file) in two locations:

1. /includes/extra_configures/time_zone_offset.php
2. /YOUR_ADMIN/includes/extra_configures/time_zone_offset.php


The file will look similar to:
<?php // Full list of timezones here: http://php.net/manual/en/timezones.php // // You can modify the TZ (Time Zone) by using a named Country/City // eg: // TZ=America/Los_Angeles // TZ=America/Denver; // TZ=America/Chicago // TZ=America/Costa_Rica; putenv ('TZ=America/New_York'); ``` The link to the php.net site contains a list of all the valid TZ environment variable values.
30 Oct 2013, 11:30 PM
#64
oavs avatar

oavs

Totally Zenned

Join Date:
Jan 2006
Location:
Downunder - QLD - Gold Coast
Posts:
921
Plugin Contributions:
0

Re: Time Zone Fix Support Thread

Hi can the file 'includes\classes\db\mysql\query_factory.php' be used in version 1.5.1 as it over writes the existing version file?

Downunder QLD

31 Oct 2013, 6:10 AM
#65
gilby avatar

gilby

Totally Zenned

Join Date:
Aug 2005
Location:
Vic, Oz
Posts:
1,816
Plugin Contributions:
0

Re: Time Zone Fix Support Thread

oavs:

Hi can the file 'includes\classes\db\mysql\query_factory.php' be used in version 1.5.1 as it over writes the existing version file?NO, This part of the code is already in the 1.5 series and is NOT needed. DON'T over write this file.

2 files from this mod are needed. See Post# 63

13 Nov 2013, 6:01 AM
#66
woodymon avatar

woodymon

Totally Zenned

Join Date:
Sep 2004
Posts:
2,309
Plugin Contributions:
1

Re: Time Zone Fix Support Thread

Scenario: ZC shop located in Pacific TZ.

ZC 1.37 shop hosted on a server in Central TZ, running PHP 5.4.15 with the ZC 'Time Zone Offset' mod installed, and -2 offset set under Admin > Config > My Store. Everything seemed good.

Sometime after payment module callbacks and the admin header began showing a two hour difference. Just let it go as it was not a bid deal. Shop order status updates and customer emails went out with proper time stamps.

Then installed fresh clean zc 1.51 on the same server for testing and noted everything in admin showed up as 0 GMT (eight hours ahead). Setting Admin > Config >MyStore to a -8 offset appeared to did nothing.

Then account was moved to a new server, still in the Central TZ, but with PHP 5.4.20. But same issue observed.

So followed Time Zone Fix readme instructions (and instructions in this thread) for ZC 1.51, editing the two time_zone_offset.php files (for the Pacific TZ), and uploading to the catalog and admin side.

putenv ('TZ=America/Los_Angeles');

But everything in admin still shows up as 0 GMT.

I don't have access to php.ini, but I requested the host to edit for Pacific TZ environment variable. Everything in admin still shows up 0 GMT. However began to observe errors similar to the following in server error log:

PHP Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone.  

Just requested the webhost to double check the php.ini change to see if spelling is correct. But from the error message above, it appears the ecommerce app should be managing the time zone, not letting the "system" do so.

Not sure why unable to configure ZC 1.51 for the proper TZ, where I was able to do so in ZC 1.37 (for awhile anyway).

Does the issue possibly have anything to do with the PHP version?.

P.S. What exactly dos the Time Off set entry in Admin > Config > My Store suppose to do? Is that part of core, or is that a leftover mod remnant still in the database?

13 Nov 2013, 6:52 AM
#67
woodymon avatar

woodymon

Totally Zenned

Join Date:
Sep 2004
Posts:
2,309
Plugin Contributions:
1

Re: Time Zone Fix Support Thread

Well, I was wrong. Web host said he didn't alter the php.ini for the current running version og php (5.4.20 native). Stated he set up PHP 5.5 with a customized time zone, and wanted me to test using the PHP switcher in ControlPanel. But I repeated that ZC 1.51 is not supported on PHP 5.5

http://www.zen-cart.com/content.php?48-what-are-the-server-requirements-to-run-zen-cart

So with ZC 1.52 slated to support PHP 5.5, i think I will just wait to work on solving all these PHP flags showing up in my debug, and various error logs. Hope to see 1.52 sooner than later.

13 Nov 2013, 9:03 AM
#69
gilby avatar

gilby

Totally Zenned

Join Date:
Aug 2005
Location:
Vic, Oz
Posts:
1,816
Plugin Contributions:
0

Re: Time Zone Fix Support Thread

Woodymon:

Solved... i missed seeing the ZC date.timezone patch patch released in June.

http://www.zen-cart.com/showthread.php?208662-date-timezone-patch-for-v1-5-1-1-5-0-1-3-9-on-PHP-5-3-5-4-5-5

No need then for the Time Zone Fix (time_zone_offset.php)Not Necessarily....
This will "fix" the php time zone.
You may still need the TZ variables to "fix" the mysql date and time stamps

14 Nov 2013, 8:23 PM
#70
woodymon avatar

woodymon

Totally Zenned

Join Date:
Sep 2004
Posts:
2,309
Plugin Contributions:
1

Re: Time Zone Fix Support Thread

gilby:

Not Necessarily....
This will "fix" the php time zone.
You may still need the TZ variables to "fix" the mysql date and time stamps

Thanks, meant to put a ? mark at end of my last sentence. So in my admin orders page Paypal is showing the correct Pacific time in it's time stamps, but the Zen Cart comment entries shows two hours ahead (Central time) for its time stamps. And so I uploaded the time-zone_fix.php in the two respective directories

putenv ('TZ=America/Los_Angeles');

but still see the timestamps in admin -> orders off by two hours.

Two questions:

  1. What does the Time Zone Offset entry in Admin >Config > MyStore suppose to do? Is that a stock zc 1.51 configuration entry? Or something leftover in the database from a previous time zone offset mod install (upgraded the zc db from 1.37 to 1.51)?

I entered "-2" in the form but appears to not be doing anything. Within phpmyadmin I don't see any function associated with that entry in the configuration table.

  1. query_factory.php Line 71 shows the following code. What is the function of "-2" in that line? Is that a hardcoded offset? Pretty certain this is the stock zc1.51 file.
if (getenv('TZ') && !defined('DISABLE_MYSQL_TZ_SET')) @mysql_query("SET time_zone = '" . substr_replace(date("O"),":",-2,0) . "'", $this->link);
14 Nov 2013, 10:01 PM
#71
gilby avatar

gilby

Totally Zenned

Join Date:
Aug 2005
Location:
Vic, Oz
Posts:
1,816
Plugin Contributions:
0

Re: Time Zone Fix Support Thread

Woodymon:

Thanks, meant to put a ? mark at end of my last sentence. So in my admin orders page Paypal is showing the correct Pacific time in it's time stamps, but the Zen Cart comment entries shows two hours ahead (Central time) for its time stamps. And so I uploaded the time-zone_fix.php in the two respective directories

putenv ('TZ=America/Los_Angeles');

but still see the timestamps in admin -> orders off by two hours.When you are in the admin is the time and date correctly shown in the header?

When you look at admin->version
Is the "Server Date" and "Database Date" the same as each other?
and are they correct?

Woodymon:

  1. What does the Time Zone Offset entry in Admin >Config > MyStore suppose to do? Is that a stock zc 1.51 configuration entry? Or something leftover in the database from a previous time zone offset mod install (upgraded the zc db from 1.37 to 1.51)?

I entered "-2" in the form but appears to not be doing anything. Within phpmyadmin I don't see any function associated with that entry in the configuration table.This is leftover from the previous "Time Zone Offset" mod. It does nothing. It can stay there without affecting anything.

Woodymon:

  1. query_factory.php Line 71 shows the following code. What is the function of "-2" in that line? Is that a hardcoded offset? Pretty certain this is the stock zc1.51 file.

if (getenv('TZ') && !defined('DISABLE_MYSQL_TZ_SET')) @mysql_query("SET time_zone = '" . substr_replace(date("O"),":",-2,0) . "'", $this->link);

14 Nov 2013, 11:58 PM
#72
woodymon avatar

woodymon

Totally Zenned

Join Date:
Sep 2004
Posts:
2,309
Plugin Contributions:
1

Re: Time Zone Fix Support Thread

I spoke to soon. All timestamps are now in alignment and showing Pacific TZ. Thanks for the info Gilby.

1 Dec 2013, 5:11 AM
#73
meljen avatar

meljen

Zen Follower

Join Date:
Apr 2012
Posts:
127
Plugin Contributions:
0

Re: Time Zone Fix Support Thread

Will this work fine for v1.5? I am in the PST/GMT-8 time and my shop is apparently 8 hours ahead of me (I guess that would make it GMT+0). I hope this mod will fix the fact that my sales always end 8 hours too early..?

1 Dec 2013, 7:04 AM
#74
gilby avatar

gilby

Totally Zenned

Join Date:
Aug 2005
Location:
Vic, Oz
Posts:
1,816
Plugin Contributions:
0

Re: Time Zone Fix Support Thread

meljen:

Will this work fine for v1.5? I am in the PST/GMT-8 time and my shop is apparently 8 hours ahead of me (I guess that would make it GMT+0). I hope this mod will fix the fact that my sales always end 8 hours too early..?See Posts 64 and 65
The query factory part is built in to 1.5.0 and 1.5.1
DON'T upload that file of this mod.

The "other" 2 files with the TZ variables are what you need.

30 Apr 2015, 3:49 AM
#75
anthonyh avatar

anthonyh

New Zenner

Join Date:
Jun 2013
Location:
Melbourne, Australia
Posts:
12
Plugin Contributions:
0

Re: Time Zone Fix Support Thread

I was looking for an update to this file. Have since discovered that with version 1.5.4 + of Zen Cart to make you zone the one where you are situated (and not where your site server is located) the solution is simple. For earlier versions still look at this line:

https://www.zen-cart.com/showthread.php?208662-date-timezone-patch-for-v1-5-1-1-5-0-1-3-9-on-PHP-5-3-5-4-5-5&highlight=%2Btime+%2Bzone

As mentioned I am using 1.5.4, so all I needed to do was:

a) Open /includes/extra_configures/set_time_zone.php
b) Go to the following line:
c) $TZ = ‘’; // eg: ‘Europe/Oslo’
d) Change to:
e) $TZ = ‘Australia/Melbourne’; // eg.’Europe/Oslo’
f) Upload the file

Use the following to find you location:

http://php.net/manual/en/timezones.php

I hope this saves at least one person a lot of time!

30 Apr 2015, 4:20 AM
#76
gilby avatar

gilby

Totally Zenned

Join Date:
Aug 2005
Location:
Vic, Oz
Posts:
1,816
Plugin Contributions:
0

Re: Time Zone Fix Support Thread

anthonyh:

I was looking for an update to this file. Have since discovered that with version 1.5.4 + of Zen Cart to make you zone the one where you are situated (and not where your site server is located) the solution is simple. For earlier versions still look at this line:

https://www.zen-cart.com/showthread.php?208662-date-timezone-patch-for-v1-5-1-1-5-0-1-3-9-on-PHP-5-3-5-4-5-5&highlight=%2Btime+%2Bzone

As mentioned I am using 1.5.4, so all I needed to do was:

a) Open /includes/extra_configures/set_time_zone.php
b) Go to the following line:
c) $TZ = ‘’; // eg: ‘Europe/Oslo’
d) Change to:
e) $TZ = ‘Australia/Melbourne’; // eg.’Europe/Oslo’
f) Upload the file

Use the following to find you location:

http://php.net/manual/en/timezones.php

I hope this saves at least one person a lot of time!

With Zen v1.5.4
Be sure that you don't alter the admin side files (because that set_time_zone.php file is automatically used by both the admin and non-admin).

6 May 2015, 8:34 PM
#77
IDEASLady avatar

IDEASLady

Totally Zenned

Join Date:
Aug 2005
Location:
Trujillo Alto, Puerto Rico
Posts:
1,455
Plugin Contributions:
4

Re: Time Zone Fix Support Thread

After doing this fix the invoices and packing slips continue showing server time. Is there a way to solve this?

IDEASLady
IDEAS Creative Studio

Your image... our business!

6 May 2015, 10:57 PM
#78
gilby avatar

gilby

Totally Zenned

Join Date:
Aug 2005
Location:
Vic, Oz
Posts:
1,816
Plugin Contributions:
0

Re: Time Zone Fix Support Thread

ideasgirl:

After doing this fix the invoices and packing slips continue showing server time. Is there a way to solve this?
What version of Zen-Cart?
Which version of this mod?

What does Admin-Version "Server Date" and "Database Date" show for the time? (They should be the same)
What is shown in the Admin header for the date/time?
These 3 should ALL show the new date and time

6 May 2015, 11:27 PM
#79
IDEASLady avatar

IDEASLady

Totally Zenned

Join Date:
Aug 2005
Location:
Trujillo Alto, Puerto Rico
Posts:
1,455
Plugin Contributions:
4

Re: Time Zone Fix Support Thread

gilby:

What version of Zen-Cart?
Which version of this mod?

What does Admin-Version "Server Date" and "Database Date" show for the time? (They should be the same)
What is shown in the Admin header for the date/time?
These 3 should ALL show the new date and time
ZC v1.5.1
TimeFix: Latest

Where do I see the "Database Date"? (Is that the one for example that shows on "date purchased"?)
The admin header time shows the date/time of customer as wanted.

When I do a backup with the MySql Backup it indicates the date/time correctly as the header.

I will recheck the issue with the customer again, since I haven't got the confirmation yet that he continues having the issue.

IDEASLady
IDEAS Creative Studio

Your image... our business!

7 May 2015, 1:55 AM
#80
gilby avatar

gilby

Totally Zenned

Join Date:
Aug 2005
Location:
Vic, Oz
Posts:
1,816
Plugin Contributions:
0

Re: Time Zone Fix Support Thread

ideasgirl:

ZC v1.5.1
TimeFix: Latest

Where do I see the "Database Date"? (Is that the one for example that shows on "date purchased"?)
The admin header time shows the date/time of customer as wanted.

When I do a backup with the MySql Backup it indicates the date/time correctly as the header.

I will recheck the issue with the customer again, since I haven't got the confirmation yet that he continues having the issue.
Admin->Version will show a line like

Server Date: 07/05/2015 11:43:56 Database Date: 07/05/2015 11:43:56

As the admin shows the correct date/time then we know that PHP has the correct time
The core 1.5.1 code will take this and set the Database Time, (assuming you haven't altered the default query_factory.php)

The mod won't fix any date/times on orders that are already in the database
It will only "fix" new orders placed after the mod is added