Magento Forum

   
Date input field format problem fixed
 
bignm
Jr. Member
 
Avatar
Total Posts:  19
Joined:  2008-07-28
Texas
 

If you have been having problems with dates in the backend (Admin) or frontend (Site), then I may have the solution for you.

I noticed that when I entered either “Special Price From Date”, “Special Price To Date”, “Set Product as New from Date”, or “Set Product as New to Date” either using direct entry or using the calendar, they would save just fine.  But… when re-editing the same field later it turns out the date would be missing the day of the month.

For example:  October 10, 2008 would display as “10//08” when it was originally entered as “10/10/08”.

It turns out to be a problem with the ‘%e’ date format conversion operator going from datetime to string.  It doesn’t work right.

So, after a lot of debugging, I found the most “universal” solution to it, that is, always use the ‘%d’ operator since it works fine.

I tracked it down to the file (Magento v1.1.6 full install):

.../magento/app/code/core/Mage/Core/Model/Locale.php lines 379 to 381.  Change the following:

$convert = array('yyyy-MM-ddTHH:mm:ssZZZZ'=>'%c',   'EEEE'=>'%A',   'EEE'=>'%a','D'=>'%j',
                         
'MMMM'=>'%B',  'MMM'=>'%b',        'MM'=>'%m',     'M'=>'%m',  'dd'=>'%d',
                         
'd'=>'%e',     'yyyy'=>'%Y',       'yy'=>'%y');

to the folowing code:

$convert = array('yyyy-MM-ddTHH:mm:ssZZZZ'=>'%c',   'EEEE'=>'%A',   'EEE'=>'%a','D'=>'%j',
                         
'MMMM'=>'%B',  'MMM'=>'%b',        'MM'=>'%m',     'M'=>'%m',  'dd'=>'%d',
                         
'd'=>'%d',     'yyyy'=>'%Y',       'yy'=>'%y');

Note the ‘d’=>’%d’ in the third line of code makes all the difference.  Now, all your dates will work properly now.

Happy E-Commerce!  grin

Tom

 
Magento Community Magento Community
Magento Community
Magento Community
 
i960
Guru
 
Avatar
Total Posts:  633
Joined:  2007-10-01
Bakersfield, CA
 

Thank you!  It’s already listed as a bug here: http://www.magentocommerce.com/bug-tracking/issue?issue=3010 Hopefully Varien will see this thread and apply your fix to 1.1.7.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Anton Makarenko
Magento Team
 
Avatar
Total Posts:  184
Joined:  2008-05-13
Los Angeles, CA
 

We see that, tnx.

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