PDA

View Full Version : Date format



DesiTesh
15 Feb 2010, 12:39 PM
hi,

How do I convert or format object date to proper format:



var jSource = '[{"startDateTime":1296547920000}]';
var myReader=new Ext.data.JsonReader({},[{name:'startDateTime'}])
..
defaultType: 'datefield',
items: [{
fieldLabel: 'Start Date', // display only date here
name: 'startDateTime',
id: 'startDateTime',
vtype: 'daterange',
format:'U'
},
new Ext.form.TimeField({
fieldLabel: 'Start Time', //display only time here
name: 'startDateTime',
})
....


Date field displays: 1296547920000, how to make it display in mm/dd/yy format ?
Also how can I get only the time value from "startDateTime" ?

Eugen_
15 Feb 2010, 10:35 PM
Hi DesiTesh,

'1296547920000' is javascript millisecond timestamp?

Try this:



{ name:'startDateTime', type: 'date', dateFormat: 'time' }




Also how can I get only the time value from "startDateTime" ?
Something like this:



getValue().dateFormat('g:i a');

Mike Robinson
16 Feb 2010, 8:06 AM
Look also for my previous forum posts.

DesiTesh
16 Feb 2010, 9:56 AM
Okay now Date display part is working, But dont know how to get just time out of that var.



..
defaultType: 'datefield',
items: [{
fieldLabel: 'Start Date',
name: 'startDateTime', //displaying date
id: 'startDateTime',
format:'m/d/y',
},
new Ext.form.TimeField({
fieldLabel: 'Start Time',
name: 'startTime', //how to display time ???
minValue: '8:00am',
maxValue: '6:00pm'
}),
..


Questions:
1. How to display just time in 'startTime' ??
2. Can I use separate id name for TimeField as 'startTime'
3. When I submit form how can we get back time & date into javascript millisecond timestamp? as it need to be saved in DB in that format.

Appreciate you help.

DesiTesh
16 Feb 2010, 10:08 AM
Never mind I got the date & time working.

I just need how to convert them back to javascript millisecond timestamp before sending to server or DB ?