Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Cookie Dates 5 Hours ahead - server time and magento both synced…. 
 
markf
Sr. Member
 
Total Posts:  145
Joined:  2007-09-20
 

I have been having some lost sessions issues like many people around here.  I just noticed that my cookies are being create with a date that is 5 hours in the future.  I checked with my host and the time is correct there. (eastern) and I also check my magento settings (eastern time).  So i cannot figure out why this is happening.

Also, I generated a new google sitemap and checked the date.... also 5 hours in the future.... any ideas???

PS
using 1.2.1.1

 
Magento Community Magento Community
Magento Community
Magento Community
 
gabrielk
Sr. Member
 
Avatar
Total Posts:  83
Joined:  2007-11-30
 

We’ve got the exact same issue happening; our server is CDT (GMT -5 hours) and it’s also set to Central time in Magento, but there’s several times when date() calls are performed when it returns the time in UTC (GMT+0 hours, effectively), thereby causing some dates and times to be off by 5 hours.  What we did to fix it is:

1) Ensured the clock on our webserver was set to the correct time and time zone: http://www.wikihow.com/Change-the-Timezone-in-Linux
2) Ensured that PHP is set to the correct time zone: http://www.electrictoolbox.com/correct-php-timezone/
3) Ensured that Magento was also set to the correct time zone (System -> Configuration -> General)
4) Changed the default time zone in Magento from UTC to our timezone: edit app/code/core/Mage/Core/Model/Locale.php
Find line 30 and change to:

//const DEFAULT_TIMEZONE  = 'UTC';
const DEFAULT_TIMEZONE  'America/Chicago'// Use your time zone as found in http://www.php.net/manual/en/timezones.php

Chances are high that your web server is already set up correctly, and if you’re not running a dedicated server your host will be the one to determine steps 1 & 2.  Steps 3-4 are the important ones for you to do.  Note that because you’re editing a core file, your changes will have to be re-applied each time you upgrade (as necessary).

 
Magento Community Magento Community
Magento Community
Magento Community
 
constructmedia
Member
 
Avatar
Total Posts:  42
Joined:  2009-04-06
 

Just wanted to say thanks for the advice been driving me crazy for ages, Great Job.

Cheers
Ryan

 
Magento Community Magento Community
Magento Community
Magento Community
 
Emico
Member
 
Total Posts:  51
Joined:  2009-07-22
Netherlands
 
gabrielk - 18 June 2009 07:32 AM

We’ve got the exact same issue happening; our server is CDT (GMT -5 hours) and it’s also set to Central time in Magento, but there’s several times when date() calls are performed when it returns the time in UTC (GMT+0 hours, effectively), thereby causing some dates and times to be off by 5 hours.  What we did to fix it is:

1) Ensured the clock on our webserver was set to the correct time and time zone: http://www.wikihow.com/Change-the-Timezone-in-Linux
2) Ensured that PHP is set to the correct time zone: http://www.electrictoolbox.com/correct-php-timezone/
3) Ensured that Magento was also set to the correct time zone (System -> Configuration -> General)
4) Changed the default time zone in Magento from UTC to our timezone: edit app/code/core/Mage/Core/Model/Locale.php
Find line 30 and change to:

//const DEFAULT_TIMEZONE  = 'UTC';
const DEFAULT_TIMEZONE  'America/Chicago'// Use your time zone as found in http://www.php.net/manual/en/timezones.php

Chances are high that your web server is already set up correctly, and if you’re not running a dedicated server your host will be the one to determine steps 1 & 2.  Steps 3-4 are the important ones for you to do.  Note that because you’re editing a core file, your changes will have to be re-applied each time you upgrade (as necessary).

This works not in Magento 1.4.1.1.
I found in app/Mage.php on line 646 that Magento sets the default_timezone tot ‘UTC’.

This ensures that it goes wrong, the value in the configuration state is thus ignored.

Anyone have any idea why Magento do this?
It seems they want to compare the installation date, but why do they will not try this?

date_default_timezone_set(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);

 
Magento Community Magento Community
Magento Community
Magento Community
 
sexiaoxiang
Jr. Member
 
Total Posts:  15
Joined:  2010-01-08
 

oh,Could I do in magento1.4.2 ?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Andre N
Sr. Member
 
Avatar
Total Posts:  186
Joined:  2009-12-09
CA
 
Yoohannuzz - 25 October 2010 02:10 AM

gabrielk - 18 June 2009 07:32 AM
We’ve got the exact same issue happening; our server is CDT (GMT -5 hours) and it’s also set to Central time in Magento, but there’s several times when date() calls are performed when it returns the time in UTC (GMT+0 hours, effectively), thereby causing some dates and times to be off by 5 hours.  What we did to fix it is:

1) Ensured the clock on our webserver was set to the correct time and time zone: http://www.wikihow.com/Change-the-Timezone-in-Linux
2) Ensured that PHP is set to the correct time zone: http://www.electrictoolbox.com/correct-php-timezone/
3) Ensured that Magento was also set to the correct time zone (System -> Configuration -> General)
4) Changed the default time zone in Magento from UTC to our timezone: edit app/code/core/Mage/Core/Model/Locale.php
Find line 30 and change to:
//const DEFAULT_TIMEZONE  = 'UTC';
const DEFAULT_TIMEZONE  'America/Chicago'// Use your time zone as found in http://www.php.net/manual/en/timezones.php

Chances are high that your web server is already set up correctly, and if you’re not running a dedicated server your host will be the one to determine steps 1 & 2.  Steps 3-4 are the important ones for you to do.  Note that because you’re editing a core file, your changes will have to be re-applied each time you upgrade (as necessary).

This works not in Magento 1.4.1.1.
I found in app/Mage.php on line 646 that Magento sets the default_timezone tot ‘UTC’.

This ensures that it goes wrong, the value in the configuration state is thus ignored.

Anyone have any idea why Magento do this?
It seems they want to compare the installation date, but why do they will not try this?

date_default_timezone_set(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);

He is absolutely right. I am using 1.5.0.1 and tried changing Locale.php on magento core as specified in step 4 above, but it was not successful. Not only did it not work, but it threw errors in the system log.
I changed it in app/Mage.php and it is working perfectly now. Just wish there was a way to make the change permanent…
Hopefully this bug is fixed so when I upgrade it will work still.

 
Magento Community Magento Community
Magento Community
Magento Community
 
devopensource
Member
 
Avatar
Total Posts:  42
Joined:  2008-04-23
spain
 

im change in: app/code/core/Mage/Core/Model/locale.php

public function storeTimeStamp($store=null)
    
{
        $timezone 
Mage::app()->getStore($store)->getConfig(self::XML_PATH_DEFAULT_TIMEZONE);
        
$currentTimezone = @date_default_timezone_get();
        @
date_default_timezone_set($timezone);
        
$date date('Y-m-d H:i:s');
       
//overwrite this line
       //@date_default_timezone_set($currentTimezone);
        
@date_default_timezone_set("Europe/Madrid");
        return 
strtotime($date);
    
}

is work!! but..... is good action? thx

 
Magento Community Magento Community
Magento Community
Magento Community
 
Andre N
Sr. Member
 
Avatar
Total Posts:  186
Joined:  2009-12-09
CA
 
seeal - 01 June 2011 12:26 AM

im change in: app/code/core/Mage/Core/Model/locale.php

public function storeTimeStamp($store=null)
    
{
        $timezone 
Mage::app()->getStore($store)->getConfig(self::XML_PATH_DEFAULT_TIMEZONE);
        
$currentTimezone = @date_default_timezone_get();
        @
date_default_timezone_set($timezone);
        
$date date('Y-m-d H:i:s');
       
//overwrite this line
       //@date_default_timezone_set($currentTimezone);
        
@date_default_timezone_set("Europe/Madrid");
        return 
strtotime($date);
    
}


is work!! but..... is good action? thx

No, it’s really not the best way to fix this. The best way would be to create yourself a module that updates this function without changing the core file.

The next best way would be to copy this file to app/code/local/Mage/Core/Model/locale.php
That way when you upgrade Magento your change won’t be overridden

That’s just for the locale.php file though… I don’t know if there is a way to modify Mage.php which is what I had to modify to make this work. Anyone?

 
Magento Community Magento Community
Magento Community
Magento Community
 
glaDiator
Member
 
Avatar
Total Posts:  65
Joined:  2008-03-17
 

Set your Timezone here -

System->Configuration->General->Locale Options
 
Magento Community Magento Community
Magento Community
Magento Community
 
kachuru
Jr. Member
 
Total Posts:  4
Joined:  2010-11-26
 

Also had issues with the magento timezone being different to the server timezone, and then Magento arbitrarily changing the timezone to UTC anyway. This really doesn’t make a whole load of sense.

The particular issue we had was magento was set to europe/budapest, and the server was set to europe/london.

This meant a cron job configured to run at 1am actually ran at 12am. And then a date function returned time in UTC to be 11pm of the day before. This threw out a whole load of calculations and caused unpredictable results. I imagine this problem would be even worse the more shifted you are from UTC.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top