Mikepo Posted November 26, 2015 Posted November 26, 2015 Hi, I'm setting up a new site using 2.3.4 BS edge and can't get the date format right, the DATEPICKER keeps returning mm/dd/yyyy, I want dd/mm/yyyy. I've made the changes to the english.php file, for defining a UK site, as defined below. Can anyone advise? define('DATE_FORMAT_SHORT', '%d/%m/%Y'); // this is used for strftime()define('DATE_FORMAT_LONG', '%A %d %B, %Y'); // this is used for strftime()define('DATE_FORMAT', 'd/m/Y'); // this is used for date()define('DATE_TIME_FORMAT', DATE_FORMAT_SHORT . ' %H:%M:%S');define('JQUERY_DATEPICKER_I18N_CODE', 'en_GB'); // leave empty for en_US; see http://jqueryui.com/demos/datepicker/#localizationdefine('JQUERY_DATEPICKER_FORMAT', 'dd/mm/yy'); // see http://docs.jquery.com/UI/Datepicker/formatDate////// Return date in raw format// $date should be in format mm/dd/yyyy// raw date is in format YYYYMMDD, or DDMMYYYYfunction tep_date_raw($date, $reverse = false) { if ($reverse) { return substr($date, 0, 2) . substr($date, 3, 2) . substr($date, 6, 4); } else { return substr($date, 6, 4) . substr($date, 3, 2) . substr($date, 0, 2); } Regards Mike osC CE live - developing osC Phoenix adding modules with no core changes(awesome and easy!)
piernas Posted November 27, 2015 Posted November 27, 2015 I didn't use the datepicker on a 2.3 shop but this worked for me on a 2.2 shop when I added the control: $( "#datepicker" ).datepicker({ dateFormat: "dd-mm-yy" }); });
milerwan Posted August 10, 2016 Posted August 10, 2016 After many tests, the sentence "define('JQUERY_DATEPICKER_FORMAT', 'dd/mm/yy'); // see http://docs.jquery.c...cker/formatDate" located in main language file (english or french, etc.) has no effect on the Datepicker JQuery module (includes/modules/header_tags/ht_datepicker_jquery.php).To fix the date format depending language (for exemple "dd//mm//yy" for "fr") you have to modify the "ht_datepicker_jquery.php" file like that : function execute() { global $PHP_SELF, $oscTemplate; if (tep_not_null(MODULE_HEADER_TAGS_DATEPICKER_JQUERY_PAGES)) { $pages_array = array(); foreach (explode(';', MODULE_HEADER_TAGS_DATEPICKER_JQUERY_PAGES) as $page) { $page = trim($page); if (!empty($page)) { $pages_array[] = $page; } } if (in_array(basename($PHP_SELF), $pages_array)) { // $oscTemplate->addBlock('<script src="ext/datepicker/js/bootstrap-datepicker.js"></script>' . "\n", $this->group); if (JQUERY_DATEPICKER_I18N_CODE == 'fr') { $oscTemplate->addBlock('<script src="ext/datepicker/js/bootstrap-datepicker.fr.js"></script>' . "\n", $this->group); } else { $oscTemplate->addBlock('<script src="ext/datepicker/js/bootstrap-datepicker.js"></script>' . "\n", $this->group); } $oscTemplate->addBlock('<link rel="stylesheet" href="ext/datepicker/css/datepicker.css" />' . "\n", 'header_tags'); // create_account // account edit // $oscTemplate->addBlock('<script>$(\'#dob\').datepicker({dateFormat: \'' . JQUERY_DATEPICKER_FORMAT . '\',viewMode: 2});</script>', $this->group); $oscTemplate->addBlock('<script>$(\'#dob\').datepicker({viewMode: 2});</script>', $this->group); // advanced search // $oscTemplate->addBlock('<script>var nowTemp = new Date(); var now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), 0, 0, 0, 0); $(\'#dfrom\').datepicker({dateFormat: \'' . JQUERY_DATEPICKER_FORMAT . '\',onRender: function(date) {return date.valueOf() > now.valueOf() ? \'disabled\' : \'\';}}); </script>', $this->group); $oscTemplate->addBlock('<script>var nowTemp = new Date(); var now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), 0, 0, 0, 0); $(\'#dfrom\').datepicker({onRender: function(date) {return date.valueOf() > now.valueOf() ? \'disabled\' : \'\';}}); </script>', $this->group); // $oscTemplate->addBlock('<script>$(\'#dto\').datepicker({dateFormat: \'' . JQUERY_DATEPICKER_FORMAT . '\',onRender: function(date) {return date.valueOf() > now.valueOf() ? \'disabled\' : \'\';}});</script>', $this->group); $oscTemplate->addBlock('<script>$(\'#dto\').datepicker({onRender: function(date) {return date.valueOf() > now.valueOf() ? \'disabled\' : \'\';}});</script>', $this->group); } } } Next step is to create the "bootstrap-datepicker.fr.js' file by editing the genuine "bootstrap-datepicker.js" (ext/datepicker/js/bootstrap-datepicker.js) file like this : At line 26, find : this.format = DPGlobal.parseFormat(options.format||this.element.data('date-format')||'mm/dd/yyyy'); and replace by : this.format = DPGlobal.parseFormat(options.format||this.element.data('date-format')||'dd/mm/yyyy'); If you want french translation for days and months, find at line 372 : days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"], daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"], daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"], months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] And replace it by : days: ["dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi", "dimanche"], daysShort: ["dim", "lun", "mar", "mer", "jeu", "ven", "sam", "dim"], daysMin: ["di", "lu", "ma", "me", "je", "ve", "sa", "di"], months: ["janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"], monthsShort: ["janv", "févr", "mars", "avril", "mai", "juin", "juil", "août", "sept", "oct", "nov", "déc"] Save the file as "bootstrap-datepicker.fr.js" and all will work now. Osc v2.3.4 BS "custom" PHP 7.3 compatible (710 modified files => o_O')
Recommended Posts
Archived
This topic is now archived and is closed to further replies.