Jump to content

[SOLVED] Why date format is inverted in Prestashop?


Recommended Posts

Hello!

I wondering why my Prestashop date format looks like this:

2011-05-09 instead 09-05-2011 (Brazilian format) or even 05-09-2011 (USA Format)

I need to fix this. I searched all the tabs in BO and found nothing. Can someone tell me where is this configuration setup?

Thanks in advance.

JR

Link to comment
Share on other sites

Hi,

If your iso country code for brazil is : "br", you can change the display date in the /classes/Tools.php classe, like this :
Replace

   public static function displayDate($date, $id_lang, $full = false, $separator='-')
   {
        if (!$date OR !strtotime($date))
            return $date;
       if (!Validate::isDate($date) OR !Validate::isBool($full))
           die (self::displayError('Invalid date'));
        $tmpTab = explode($separator, substr($date, 0, 10));
        $hour = ' '.substr($date, -8);

       $language = Language::getLanguage((int)($id_lang));
        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 :

   public static function displayDate($date, $id_lang, $full = false, $separator='-')
   {
        if (!$date OR !strtotime($date))
            return $date;
       if (!Validate::isDate($date) OR !Validate::isBool($full))
           die (self::displayError('Invalid date'));
        $tmpTab = explode($separator, substr($date, 0, 10));
        $hour = ' '.substr($date, -8);

       $language = Language::getLanguage((int)($id_lang));
        if ($language AND strtolower($language['iso_code']) == 'fr')
            return ($tmpTab[2].'-'.$tmpTab[1].'-'.$tmpTab[0].($full ? $hour : ''));
        elseif ($language AND strtolower($language['iso_code']) == 'br')
            return ($tmpTab[1].'-'.$tmpTab[2].'-'.$tmpTab[0].($full ? $hour : ''));
        else
            return ($tmpTab[0].'-'.$tmpTab[1].'-'.$tmpTab[2].($full ? $hour : ''));
   }



I've no tested.

Regards

Link to comment
Share on other sites

×
×
  • Create New...