EasyUI Forum
April 23, 2024, 04:44:19 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Format a text box dd/mm/yyyy  (Read 10405 times)
peter900
Newbie
*
Posts: 22


View Profile Email
« 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.



Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #1 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=
Logged
peter900
Newbie
*
Posts: 22


View Profile Email
« Reply #2 on: June 13, 2017, 03:34:33 AM »

Thanks for your prompt help on this - which answered my problem. 


Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!