Feb 01, 2012, 11:01 AM
[CLOSED] Date is a string instead of Date object
Checkout this following sitation pls:
Store:
Why?
I've needed to get Date object like this:
Thanks.
Store:
<ext:Store ID="stoCandidate" runat="server" RemoteSort="true" OnRefreshData="Store_Refresh">
<Reader>
<ext:JsonReader IDProperty="CandidateId">
<Fields>
....
<ext:RecordField Name="EngtThruDate" Type="Date" ServerMapping="EngtThruDate" />
<ext:RecordField Name="DaysToExpire" Type="Int">
<Convert Fn="getDaysToExpire" />
</ext:RecordField>
</Fields>
</ext:JsonReader>
</Reader>
.....
JS:
// returns date difference in days
var getDateDiffDays = function(first_date, second_date) {
//round it to prevent daylight savings issues (missing or extra hour)
return Math.round((first_date - second_date) / (1000 * 60 * 60 * 24));
}
var getDaysToExpire = function(value,record){
var curDate = new Date();
return getDateDiffDays(record.EngtThruDate, curDate);
}
The example above returns 'NaN' value for "DaysToExpire" column!?Why?
I've needed to get Date object like this:
var getDaysToExpire = function(value,record){
var curDate = new Date();
return getDateDiffDays(Date.parseDate(record.EngtThruDate, "Y-m-dTH:i:s.u"), curDate);
}
Thanks.
Last edited by Daniil; Feb 07, 2012 at 4:57 PM.
Reason: [CLOSED]