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
Post a Comment