How to subtract date/time in javascript? -


this question has answer here:

i have field @ grid containing date/time , need know difference between , current date/time. best way of doing so?

this give difference between 2 dates, in milliseconds

var diff = math.abs(date1 - date2); 

in example, it'd be

var diff = math.abs(new date() - comparedate); 

you need make sure comparedate valid date object.

something work you

var diff = math.abs(new date() - new date(datestr.replace(/-/g,'/'))); 

i.e. turning "2011-02-07 15:13:06" new date('2011/02/07 15:13:06'), format date constructor can comprehend.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -