Jump to content

[Solved]Date format


Recommended Posts

Is it just the date on the PDF you want to change or all dates? You can change all dates by changing lines 334-337 (in PrestaShop v1.3.2) of classes/Tools.php:

/*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[0].'. '.$tmpTab[2].'. '. date("F", mktime(0, 0, 0, $tmpTab[1], 1, 2005));



This will display "2010. 06. October" instead of "2010-10-06".

Link to comment
Share on other sites

You would remove all the Tools::displayDate calls in classes/PDF.php and write your own code to format the dates.

Making the text translatable would be more difficult. I think you may need to create an array of the 12 month names for each language, then use that array instead of the date function to convert the month number to the month name.

Link to comment
Share on other sites

Something like this in the displayDate function should work:

$month = array(1 => array('01' => 'January', '02' => 'February', '03' => 'March', '04' => 'April', '05' => 'May', '06' => 'June', '07' => 'July', '08' => 'August', '09' => 'September', '10' => 'October', '11' => 'November', '12' => 'December'),
2 => array('01' => 'January', '02' => 'February', '03' => 'March', '04' => 'April', '05' => 'May', '06' => 'June', '07' => 'July', '08' => 'August', '09' => 'September', '10' => 'October', '11' => 'November', '12' => 'December'),
3 => array('01' => 'January', '02' => 'February', '03' => 'March', '04' => 'April', '05' => 'May', '06' => 'June', '07' => 'July', '08' => 'August', '09' => 'September', '10' => 'October', '11' => 'November', '12' => 'December'));



Change the months in 2 to French and 3 to Spanish. Add more lines if necessary. You should then be able to use the following code:

return $tmpTab[0].'. '.$tmpTab[2].'. '. $month[$id_lang][$tmpTab[1]];

Link to comment
Share on other sites

  • 2 months later...

Feature request is already there - I added a link to this thread there:
http://www.prestashop.com/bug_tracker/view/6052/

--

UPDATE:
The coolest method is IMHO to add code for each country in Tools.php.
In this way the original functionality is always retained.

For example for german, after the If-clause (around line 344):

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


...we add:

     elseif ($language AND strtolower($language['iso_code']) == 'de')
  return ($tmpTab[2].'.'.$tmpTab[1].'.'.$tmpTab[0].($full ? $hour : ''));  // TT.MM.JJJJ

Link to comment
Share on other sites

  • 6 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...