Jump to content

Date format in BO


Recommended Posts

Did you change the format in classes/Tool.php? In the displayDate function, edit lines 344-347:

if ($language AND strtolower($language['iso_code']) == 'fr')
   return ($tmpTab[2].'-'.$tmpTab[1].'-'.$tmpTab[0].($full ? $hour : ''));
else
   return ($tmpTab[0].'-'.$tmpTab[1].'-'.$tmpTab[2].($full ? $hour : ''));



to:

/*if ($language AND strtolower($language['iso_code']) == 'fr')
   return ($tmpTab[2].'-'.$tmpTab[1].'-'.$tmpTab[0].($full ? $hour : ''));
else
   return ($tmpTab[0].'-'.$tmpTab[1].'-'.$tmpTab[2].($full ? $hour : ''));
*/
   return ($tmpTab[2].'.'.$tmpTab[1].'.'.$tmpTab[0].($full ? $hour : ''));

Link to comment
Share on other sites

Yes but as I said earlier some dates are ok but some are not. a.e the dates in Product Reduction amount available from and to, the date on Order detail Invoice #IN000004 Created on: 2011-01-02 22:12:25, calendar From: and To: in stats and home page, date in Merchandise return table and so on...

Link to comment
Share on other sites

Those reduction and calendar dates are in MySQL date format, so you can't change the format of them.

The date on the Orders tab is definitely a bug. The displayDate function isn't being called. Try changing line 560 of admin/tabs/AdminOrders.php (in PrestaShop v1.3.5) from:


'.$this->l('Created on:').' '.$order->invoice_date.'



to:


'.$this->l('Created on:').' '.Tools::displayDate($order->invoice_date, intval($cookie->id_lang), true).'

Link to comment
Share on other sites

Thx, that works but I also would the date fields in right format. I understand that is MYSQL date format but why is not possible to change the display to right format? Or is possible to change the field to read-only or text that is changed only by datepicker?

Link to comment
Share on other sites

Did you change the format in classes/Tool.php? In the displayDate function, edit lines 344-347:

if ($language AND strtolower($language['iso_code']) == 'fr')
   return ($tmpTab[2].'-'.$tmpTab[1].'-'.$tmpTab[0].($full ? $hour : ''));
else
   return ($tmpTab[0].'-'.$tmpTab[1].'-'.$tmpTab[2].($full ? $hour : ''));



to:

/*if ($language AND strtolower($language['iso_code']) == 'fr')
   return ($tmpTab[2].'-'.$tmpTab[1].'-'.$tmpTab[0].($full ? $hour : ''));
else
   return ($tmpTab[0].'-'.$tmpTab[1].'-'.$tmpTab[2].($full ? $hour : ''));
*/
   return ($tmpTab[2].'.'.$tmpTab[1].'.'.$tmpTab[0].($full ? $hour : ''));



Hi Rocky, I'd like to change the date format to dd-mm-yyyy too and tried what you have recommended. However, this modification to the code caused a number of issues to my current Prestashop v1.3.5:

1. Customer login, registration and checkout returned white black pages
2. Random or persistent errors in accessing or loading categories and product pages
3. Logging out of BO is erratic and gave blank white page

Is there another method of changing and standardising the date formats throughout the BO and FO other than modifying the codes manually? Are there any modules or new version of PS addresses this issue?

Any suggestions on this is very much appreciated as my region (Asia) uses the dd-mm-yyyy format extensively.
Link to comment
Share on other sites

No, changing the displayDate function is the only way to change the date. It shouldn't have caused any white pages. I've successfully changed my website to dd-mm-yyyy before by changing the code.


Thank you for the clarification. I gave it another try and all seems fine at the moment. Seems like I didn't do the url-friendly, generation of .htaccess file process and changing of Tools.php file's permissions properly, hence the white pages.
Link to comment
Share on other sites

×
×
  • Create New...