Zen Cart Logo
Forums / General Questions / Order timestamp doesn't match server time even though the timezone is correct

Order timestamp doesn't match server time even though the timezone is correct

Views: 3,295

Results 1 to 20 of 33
11 Apr 2014, 9:06 AM
#1
shirster avatar

shirster

Zen Follower

Join Date:
Sep 2005
Location:
Hong Kong
Posts:
301
Plugin Contributions:
0

Order timestamp doesn't match server time even though the timezone is correct

Hi all!

My server used to be on New York time while I'm located in Hong Kong, so I asked my web host to change the server to Hong Kong time for me. After that, both the current time displayed on the green bar near the top inside ZC admin and the timezone displayed on the "Server Info" page are correct, meaning they are both Hong Kong time.

But when I placed a test order, the admin showed that the order was placed in New York time, which means it was 12 hours behind Hong Kong.

BUT the timestamp in the order confirmation email that I received was correct, meaning it was indeed showing Hong Kong time.

What gives? I'm not very familiar with server / PHP stuff so any help is greatly appreciated, thank you in advance!

On my "Server Info" page:

date

date/time support enabled
"Olson" Timezone Database Version 2012.8
Timezone Database internal
Default timezone Asia/Hong_Kong

Directive Local Value Master Value
date.default_latitude 31.7667 31.7667
date.default_longitude 35.2333 35.2333
date.sunrise_zenith 90.583333 90.583333
date.sunset_zenith 90.583333 90.583333
date.timezone Asia/Hong_Kong Asia/Hong_Kong

11 Apr 2014, 4:41 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Order timestamp doesn't match server time even though the timezone is correct

You could use the files for this that are used in v1.5.2 adding:
/includes/extra_configures/set_time_zone.php

and setting your time zone for the code in RED:

<?php
/**
 * @package initSystem
 * @copyright Copyright 2003-2013 Zen Cart Development Team
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version GIT: $Id: Author: DrByte  Sat Nov 2 01:21:28 2013 -0400 New in v1.5.2 $
 */
/*
 * Set time zone
*/
if (version_compare(PHP_VERSION, 5.3, '>='))
{
  // put your timezone here. Refer to http://www.php.net/manual/en/timezones.php
[B]  $TZ = '';  // eg: 'Europe/Oslo'[/B]



  /**
   * MAKE NO CHANGES BELOW THIS LINE
   *
   * The following will take the timezone you specified above and apply it in your store.
   * If you didn't specify one, it will try to use the setting from your server's PHP configuration
   */
  if ($TZ == '') {
    $TZ = date_default_timezone_get();
  }
  if ($TZ != '') {
    putenv('TZ=' . $TZ);
    @date_default_timezone_set($TZ);
  }
}

And add to your secret admin the file:
/your_secret_admin/includes/extra_configures/use_catalog_time_zone.php

with the code:

<?php
/**
 * @package admin
 * @copyright Copyright 2003-2013 Zen Cart Development Team
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version GIT: $Id: Author: DrByte  Sat Nov 2 01:21:28 2013 -0400 New in v1.5.2 $
 */
// get time zone settings from catalog-side file
include (DIR_FS_CATALOG . '/includes/extra_configures/set_time_zone.php');

That should fix things for you ...

28 Jun 2014, 11:54 PM
#3
benxp avatar

benxp

New Zenner

Join Date:
Jul 2005
Posts:
43
Plugin Contributions:
0

Re: Order timestamp doesn't match server time even though the timezone is correct

It works!!

28 Jun 2014, 11:58 PM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Order timestamp doesn't match server time even though the timezone is correct

Thanks for the update that this is now working for you ...

1 Jul 2014, 12:08 AM
#5
benxp avatar

benxp

New Zenner

Join Date:
Jul 2005
Posts:
43
Plugin Contributions:
0

Re: Order timestamp doesn't match server time even though the timezone is correct

Hi Linda, got another small issue. Now the order time is correct but order status update still shows american time.

For exmaple, the order status "pending" time is as same as local time, but when we update the status to " delivered", the time is not local time , it still display american time. How can we change it as well? Thanks for your helps!

1 Jul 2014, 12:33 AM
#6
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Order timestamp doesn't match server time even though the timezone is correct

Which Zen Cart version are you running again? :lookaroun

1 Jul 2014, 2:19 AM
#7
benxp avatar

benxp

New Zenner

Join Date:
Jul 2005
Posts:
43
Plugin Contributions:
0

Re: Order timestamp doesn't match server time even though the timezone is correct

it is v1.5.1

1 Jul 2014, 2:30 AM
#8
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Order timestamp doesn't match server time even though the timezone is correct

You did everything in post #2 correct?

What version php are you using?

1 Jul 2014, 9:42 AM
#9
benxp avatar

benxp

New Zenner

Join Date:
Jul 2005
Posts:
43
Plugin Contributions:
0

Re: Order timestamp doesn't match server time even though the timezone is correct

Yes, I set up those two files. It is PHP Version: 5.3.26 (Zend: 2.3.0)

1 Jul 2014, 1:44 PM
#10
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Order timestamp doesn't match server time even though the timezone is correct

This is really odd ... so far, in v1.5.1, using those two files, I am unable to reproduce this issue ...

I will keep looking and see if I can make it happen on one of my other servers ...

1 Jul 2014, 2:35 PM
#11
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Order timestamp doesn't match server time even though the timezone is correct

Make a Test Order using a Test Customer account ...

When you change the status on the Order, write the time and a unique comment in the comment box to help track the order in which you are making the change ...

Try changing the status and going between Pending, Processing, Delivered and be sure to include a unique comment each time that includes the exact time ...

1 Jul 2014, 9:44 PM
#12
benxp avatar

benxp

New Zenner

Join Date:
Jul 2005
Posts:
43
Plugin Contributions:
0

Re: Order timestamp doesn't match server time even though the timezone is correct

do you mean we type the local time in comments when we change to status from pending to processcing or delivered? but the time in "date added" is still American time...

1 Jul 2014, 10:13 PM
#13
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Order timestamp doesn't match server time even though the timezone is correct

I am saying test an order with a test customer account then just as a note to yourself enter the your time in the comments when you change the status ...

NOTE: Look at the time on the Admin Menu ... is it correct?

Check the order times in the orders table via phpMyAdmin and what is set in the order status on both the time on the order and after you change the order status and check the time on the database table for the order status as well just to see what is and isn't update ...

Also, might check the customer login time ...

1 Jul 2014, 10:21 PM
#14
benxp avatar

benxp

New Zenner

Join Date:
Jul 2005
Posts:
43
Plugin Contributions:
0

Re: Order timestamp doesn't match server time even though the timezone is correct

Sure, just tried. Admin menu time is correct , Email time is also correct, because we have changed the time zone in server side. I log in placed a new order, the order time with "pending" status is correct 07/02, but after I changed the status to Processing the " date added" shows 07/01/2014 which is not local time. I will check the database time now.

1 Jul 2014, 10:29 PM
#15
benxp avatar

benxp

New Zenner

Join Date:
Jul 2005
Posts:
43
Plugin Contributions:
0

Re: Order timestamp doesn't match server time even though the timezone is correct

Hi Linday, the order status in orders_status_history table is exactly as same as what I see in the admin area, 07/02 for pending and 07/01 for processing....

2 Jul 2014, 12:33 AM
#16
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Order timestamp doesn't match server time even though the timezone is correct

What happens if you add a new Product and look in the database at the times on the products table?

Are they off too?

2 Jul 2014, 1:01 AM
#17
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Order timestamp doesn't match server time even though the timezone is correct

Just to humor me ... if you run in the Tools ... Developers Tool Kit ... in the bottom input box:
set_time_zone.php

and select Catalog/Admin and click Search ...

What comes up?

2 Jul 2014, 1:03 AM
#18
benxp avatar

benxp

New Zenner

Join Date:
Jul 2005
Posts:
43
Plugin Contributions:
0

Re: Order timestamp doesn't match server time even though the timezone is correct

Hi Linda, I just set up a new product but the date added time is not local time, it is 01 July, it is american time, should we change something in database?

2 Jul 2014, 1:05 AM
#19
benxp avatar

benxp

New Zenner

Join Date:
Jul 2005
Posts:
43
Plugin Contributions:
0

Re: Order timestamp doesn't match server time even though the timezone is correct

Line #8 : include (DIR_FS_CATALOG . '/includes/extra_configures/set_time_zone.php');

2 Jul 2014, 1:11 AM
#20
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Order timestamp doesn't match server time even though the timezone is correct

Could you actually show the file path to that without your secret admin directory name showing?