-
8 Aug 2012 1:16 PM #1
Answered: How to extract only the date from the Datefield object
Answered: How to extract only the date from the Datefield object
Hi,
I have an xtype datefield and timefield. On clicking a button, I am retrieving the values. The values, however, give information which I do not need. How can I convert these objects to string and manipulate accordingly?
For eg: the timefield returns some date, time and some text like (eastern standard time). I only want the time in hours and min and attach extra details myself.
Thanks
-
Best Answer Posted by vietits
Try this:
Code:Ext.Date.format(timefield.getValue(), 'H:i:s');
-
8 Aug 2012 5:14 PM #2
Try this:
Code:Ext.Date.format(timefield.getValue(), 'H:i:s');
-
8 Aug 2012 6:19 PM #3
If you are using any server side code then you can convert your date like the one I have done it. You can specify the required format you want. Let me know if any doubt.
Java code :
Thanks.Code:SimpleDateFormat extJSDateFormat, requiredFormat = null; Date date = null; try { extJSDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); System.out.println("Old date:" + oldDate); // String oldDate = "2011-03-10T11:54:30.207Z"; date = extJSDateFormat.parse(oldDate.substring(0, 19)); requiredFormat = new SimpleDateFormat("MM/dd/yyyy"); System.out.println("OldDate:" + oldDate); System.out.println("NewDate:" + requiredFormat.format(date)); } catch (Exception e) { e.printStackTrace(); }
J.M.
-
9 Aug 2012 6:59 AM #4
Thanks both of you. I tried this as suggested and it worked!

Code:Ext.Date.format(timefield.getValue(), 'H:i:s');


Reply With Quote