Artizzz Posted October 6, 2010 Share Posted October 6, 2010 Hello! I have problem with date format, I need to make that data format in invoice be not "2010-10-06" but "2010. year 06. October", how can I make that?Best regards Link to comment Share on other sites More sharing options...
rocky Posted October 6, 2010 Share Posted October 6, 2010 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 More sharing options...
Artizzz Posted October 6, 2010 Author Share Posted October 6, 2010 ok, this is great, big thanks.emmm... and how it's is possible to make different format for invoice and all other dates? ( just for knowing it )and where can I translate month name in my language? Link to comment Share on other sites More sharing options...
rocky Posted October 6, 2010 Share Posted October 6, 2010 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 More sharing options...
Artizzz Posted October 6, 2010 Author Share Posted October 6, 2010 maybe you can tell me how to translate it? it will be awesome, because I have no idea how to do that. Link to comment Share on other sites More sharing options...
rocky Posted October 6, 2010 Share Posted October 6, 2010 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 More sharing options...
Artizzz Posted October 6, 2010 Author Share Posted October 6, 2010 where I need to put that array code? Link to comment Share on other sites More sharing options...
rocky Posted October 6, 2010 Share Posted October 6, 2010 Above the code that was commented out will do. Link to comment Share on other sites More sharing options...
Artizzz Posted October 6, 2010 Author Share Posted October 6, 2010 yeah, it's working. thanks maybe you can tell me how can I integrate this code in pdf.php to make different format only for invoice? Link to comment Share on other sites More sharing options...
rocky Posted October 7, 2010 Share Posted October 7, 2010 I suggest that you copy the displayDate function from classes/Tools.php into classes/PDF.php, then modify it as needed, then change all Tools::displayDate references in classes/PDF.php to $this->displayDate Link to comment Share on other sites More sharing options...
Artizzz Posted October 7, 2010 Author Share Posted October 7, 2010 Big thanks, really helped. Link to comment Share on other sites More sharing options...
rocky Posted October 7, 2010 Share Posted October 7, 2010 If your issue is resolved, please edit your first post and add [sOLVED] to the front of the title. Link to comment Share on other sites More sharing options...
bb42 Posted December 7, 2010 Share Posted December 7, 2010 Sorry, isn't it a bit strange that one has to edit the source code in order to change to another date format?This should definitely be a setting for the backend! Link to comment Share on other sites More sharing options...
rocky Posted December 8, 2010 Share Posted December 8, 2010 I agree. You can post a feature request on the bug tracker. Hopefully, PrestaShop will add the option in the future. Link to comment Share on other sites More sharing options...
bb42 Posted December 8, 2010 Share Posted December 8, 2010 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 More sharing options...
matej0001 Posted April 24, 2017 Share Posted April 24, 2017 I can not translate the date in prestashop . Some ideas? Please. Does not work in translation. Prestashop 1.6.11 {$post.date_added|date_format:"%B %d %Y"} Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now