Text or Call 303.473.4400
Select Page

Magento Bug Report Summary: The Customer Account Creation Date is often wrong (i.e. Customer Account Create Date is in the past or future).


Magento versions affected:
Magento Community 1.8, 1.9; Magento Enterprise 1.12, 1.13, 1.14

Description of the Magento Bug:

We’ve seen a strange increase in issues in the Magento data where dates are switching out Months and Days.  The case may be where an account is created on February 10, 2015, but in Magento it’s recorded as October, 2.  Or you may find customer accounts where the customer has signed up in the future.  So… how is this possible?  And does it even matter?

While we’ve been searching for evidence of temporal anomalies in the space time continuum, but so far have not found evidence of time travel.

Instead, I think that this bug appeared because in the United States, dates are written MM-DD-YYYY. (02-10-2015 = Feb 10, 2015).

But in Europe and many other places, dates are written DD-MM-YYYY.  (02-10-2015 = 2nd October 2015, or Oct 2, 2015).

While Magento is based in the US, much of the development was done by programmers in the Ukraine.

Magento’s EAV (Entity Attribute Value) table structure relies on code formatting and that formatting is swapping out month and day so February 10th becomes October 2nd.

We’ve created a simple module you can install to resolve and prevent this problem going forward.  This module plugs into your Magento store and will format dates uniformly before inserting them into the database.

You can download the Magento Bug Fix for Account Creation Date for free here:
https://www.customerparadigm.com/download/Magento-Date-Switch-Fix-Extension.zip

Free Magento Extension to Fix the Magento Date Switch Bug

Need help with Magento Development or want us to install this extension for you? Call Customer Paradigm – 303.473.4400 or visit here >>

We recommend backing up your site first or doing this on a test server in case something else breaks, but this extension only contains two files (plus one in the configuration area).

Why does this bug matter?

If you’re doing any type of third party email campaigns or marketing based on when someone created an account, your data is going to be really wrong if this bug is in place.  If you’re using the account creation date for sales, personalization or marketing, you’ll likely miss some of your audience.

We found this because we were launching a brand new site Magento Community site for a client, and saw that the account creation date was in the future.  Another developer sitting three feet away had just seen this identical issue on another Magento Enterprise site.

When was this Magento bug introduced?

From our research, we found there was a change in
Mage_Eav_Model_Entity_Attribute_Backend_Time_Created
between Magento Community 1.8.0 and 1.8.1 and Magento Enterprise Edition 1.12.x and 1.13.0.

This change converts a date to UTC if it already exists. The date parameter that is sent to utcDate(null, $date, true, $this->_getFormat($date)) seems to be the problem.

The suggested fix is to convert $date to a timestamp before using it in a function:
$date = strtotime($date);

We were able to replicate the error on live and test sites, and we tested this fix by changing the Core code to verify that this was the issue.  We then built out a Magento Extension so that core code would not need to be modified.

Summary of the files in the Magento Extension for solving the Magento Date Switch Fix:

Created.php:
app/code/local/CustomerParadigm/Datefix/Model/Entity/Attribute/Backend/Time/Created.php

In this file, we have this file use this new class:  CustomerParadigm_Datefix_Model_Entity_Attribute_Backend_Time_Created to extend the  Mage_Eav_Model_Entity_Attribute_Backend_Time_Created class.

Here’s a screenshot of the code in the Created.php file:

Magento Bug Fix - Free Extension by Customer Paradigm. Created.php file to fix juxtaposition of Date Created Field.

Config.xml:
We also have the config.xml file that configures the Magento extension:
/app/code/local/CustomerParadigm/Datefix/etc/config.xml

Screenshot of the Config.xml file:

Magento Bug Fix - Free Extension by Customer Paradigm. Confix.xml file to fix juxtaposition of Date Created Field.

 

The module is registered using an XML file here:
/app/etc/module/ CustomerParadigm_Datefix.xml

<?xml version=”1.0″?>
<config>
<modules>
<CustomerParadigm_Datefix>
<active>true</active>
<codePool>local</codePool>
</CustomerParadigm_Datefix>
</modules>
</config>

Here’s a screenshot of the XML file:

Magento Bug Fix - Free Extension by Customer Paradigm. CustomerParadigm_Datefix.xml file to fix juxtaposition of Date Created Field.

If you ever want to turn this extension off, you can turn it off in this XML file, or simply remove all three files.  This extension does not create, remove, edit or add any new database tables or columns in any existing tables in the system.

Using the module allows you to not have to overwrite or modify any core code on the site to fix this issue.  This will prevent problems in the future if this is patched or your site is upgraded.  It’s important to note that you should really not ever modify core Magento code, as it can have unintended consequences for your Magento site.

This bug was reported online on Stack Exchange here:
http://magento.stackexchange.com/questions/16176/magento-1-8-1-updates-customer-created-at-time-on-every-save

http://magento.stackexchange.com/questions/3215/why-is-created-at-customer-entity-table-set-to-change-on-update

Need help with Magento Development or want us to install this extension for you? Call Customer Paradigm – 303.473.4400 or visit here >>

Pin It on Pinterest

Share This