EasyUI Forum

General Category => General Discussion => Topic started by: peter900 on June 12, 2017, 02:07:09 PM



Title: Format a text box dd/mm/yyyy
Post by: peter900 on June 12, 2017, 02:07:09 PM
I have a function that formats a cell from a MySQL db in a datagrid dd/mm/yyyy

Code:
function formatDate1(val,row){		
return formattedDate(val);
}

function formattedDate(date) {
var d = new Date(date || Date.now()),
month = '' + (d.getMonth() + 1),
day = '' + d.getDate(),
year = d.getFullYear();

if (month.length < 2) month = '0' + month;
if (day.length < 2) day = '0' + day;

return [day, month, year].join('/');
}

The edit form displays the date in a text box, as per the crud example.  I thought I could use the same function as follows:

Code:
<input name="date" class="easyui-textbox" data-options="formatter:formatDate1">

but it has no effect. 

Ideally I would like to use a datebox.  What do I need to change to display a date dd/mm/yyyy so that when the form is saved the date is yyyy/mm/dd .

Thanks.





Title: Re: Format a text box dd/mm/yyyy
Post by: jarry on June 12, 2017, 05:26:20 PM
Please look at this example https://www.jeasyui.com/demo/main/index.php?plugin=DateBox&theme=default&dir=ltr&pitem=Date%20Format&sort=


Title: Re: Format a text box dd/mm/yyyy
Post by: peter900 on June 13, 2017, 03:34:33 AM
Thanks for your prompt help on this - which answered my problem.