Question

i am using a date field which defined as

var input = $('<input id="datefield"/>');

$(input).igEditor({
               type: 3,
               datePattern: 'dd/MM/yyyy'                       
});

and i am getting the value as

var date=$("#datefield").igEditor("option","value")

which gives me date as

date=Sun Jun 05 2011 00:00:00 GMT+0400 (Arabian Standard Time)

but i want date as Sun Jun 05 2011 00:00:00

Is it possible to get date excluding the timezone. Thanks in advance

Was it helpful?

Solution

What you are seeing is the default JavaScript representation of Date object, which is what the editor will use when you specify it to be DateEditor.

To get your result first set the dataMode property to either "text" or "editModeText". This will modify the value the editor accepts and returns.

$("#datefield").igEditor({
    type: 3,
    dataMode: "text"
});

Second - use the value() method as it is modified by dataMode:

$("#datefield").igEditor("value")

Here's the JSFiddle: http://jsfiddle.net/damyanpetev/DjwsD/

Side note: the datePattern property you are setting is not correct (it just happens that the default date pattern of the control is the same). You should be using dateDisplayFormat instead (in the fiddle as well) where you have predefined date/dateLong/dateTime presets as well as the option to build it yourself exactly like you did with datePattern. The "dateTime" setting is closest to what you want I think and it is modified by the regional settings, but in case it's not perfect I've made you a pattern that matches what you want exactly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top