PDA

View Full Version : How to count days



rubynile
23 Jul 2009, 2:14 AM
How to get number of days between two dates.for example (starting date and ending date).please help me.thank you

evant
23 Jul 2009, 2:18 AM
http://extjs.com/deploy/dev/docs/?class=Date

steffenk
23 Jul 2009, 2:18 AM
pseudo code:

var delta = Date.parse(endtime) - Date.parse(starttime);
var days = parseInt(delta / 86400).toString();

rubynile
23 Jul 2009, 2:35 AM
ya i included this but its giving value as NAN

steffenk
23 Jul 2009, 2:37 AM
you included what? Code please.

rubynile
23 Jul 2009, 3:00 AM
var delta = Date.parse(endtime) - Date.parse(starttime);
var days = parseInt(delta / 86400).toString();

In my application starttime is Reseravation_Start (its value:2009-06-27)
and end time is Reseravation_End_Start (its value:2009-07-05)
so i changed it as

var delta = Date.parse(Reseravation_End_Start) - Date.parse(Reseravation_Start);
var days = parseInt(delta / 86400).toString();

This coding only i included

steffenk
23 Jul 2009, 3:25 AM
these strings are no valid time strings.

better to use Date class from ExtJS as evant already posted, then you can

var starttime = Date.parseDate('2009-06-27', 'Y-m-d');
var endtime = Date.parseDate('2009-07-05', 'Y-m-d');

rubynile
23 Jul 2009, 4:11 AM
thanks alot i got the output