How to determine how many minutes has passed in javascript
datetime, javascript
Solution
See the DOC for javascript Date
Date Constructor accepts a date string. I tried yours in chrome console it works fine. Then you can use getTime to get number of milliseconds since January 1, 1970
Finally
var past = new Date(yourTimeString).getTime();
var fiveMin = 1000 * 60 * 5;
var isPast = (new Date().getTime() - past < fiveMin)?false:true;
Problem
I have variable which I populate from JSON formated data. Something like: `var time=my_data[data.results[i].id].time;` This gives me time from database in this format : `2012-06-19 15:48:18.140` How can save in some other variable value for example `active` if the time between a value that I get from database and time which is present(now) is less then 5 min and `inactive` if it is more then 5 min passed Thank you