Title: Issue with datetimebox Post by: fonzie on May 16, 2017, 09:53:56 AM I am wanting the easyui-datetimebox to display the date and time in UK format which is "dd mm yyyy", for example today would be displayed as "16/5/2017 17:46:53".
I can get this to work (code below), but whenever I click on the calendar icon in the textbox to open the small calendar, the time displayed at the bottom is always "00:00:00" and even if I change it to something else, it doesn't get updated correctly, the current time replaces it (which I realise is because of my code). This page/site is for UK usage only, therefore if I need to change the original source code to reflect UK dates, that won't be an issue. Code :- <input class="easyui-datetimebox" value="16/5/2017" data-options="label:'mm/dd/YYYY',labelPosition:'top',formatter:ukformatter,parser:ukparser" style="width:100%;"> <script type="text/javascript"> function ukformatter(date){ var y = date.getFullYear(); var m = date.getMonth() + 1; var d = date.getDate(); //var t = date.GetTime(); var dt = new Date(); var time = dt.getHours() + ":" + dt.getMinutes() + ":" + dt.getSeconds(); // date format dd/mm/yyy var r = (d < 10 ? ('0' + d) : d) + '/' + (m < 10 ? ('0' + m) : m) + '/' + y + ' ' + time; //var r = (d < 10 ? ('0' + d) : d) + '/' + (m < 10 ? ('0' + m) : m) + '/' + y return r; } function ukparser(s){ if (!s) { return new Date(); } // date format dd/mm/yyyy var ss = (s.split('/')); var d = parseInt(ss[0], 10); var m = parseInt(ss[1], 10); var y = parseInt(ss[2], 10); if (!isNaN(y) && !isNaN(m) && !isNaN(d)) { return new Date(y, m - 1, d); } else { return new Date(); } } </script> Title: Re: Issue with datetimebox Post by: stworthy on May 17, 2017, 01:04:24 AM The 'ukformatter' and 'ukparser' functions should be defined as:
Code: function ukformatter(date){ Title: Re: Issue with datetimebox Post by: fonzie on May 17, 2017, 03:22:31 AM Thank you for the help, but unfortunately the code isn't working correctly.
The time is now displayed at the bottom of the calendar is now correct, but if I choose a different time, this isn't reflected in the text area, it also isn't choosing the correct date, if I choose today, instead of displaying "17/05/2017" it shows "17/06/2017". Title: Re: Issue with datetimebox Post by: stworthy on May 17, 2017, 05:46:01 PM Please use the 'formatter' and 'parser' functions in the previous post. This is an example that works fine.
http://code.reloado.com/eqilas/edit#javascript,html |