I'm using google sheets javascript script where I'm looping over 15 min intervals each in their own column. I'm trying to find the column that matches the current hour/min so I can highlight it but can't get the javascript time checking to work.
time and nextTime are simply times like 8:00 or 8:15, so when I convert them to Date I get something like: Sat Dec 30 1899 08:00:00 GMT-0600 (CST)
Does getTime() consider the date part or just the time part? If I have a string for the date like "10/14/2017" how could I bring the 2 together for the date object?
var now = new Date().getTime();
for(i in data[0]){
var time = new Date(data[0][i]);
var nextTime = new Date(data[0][Number(i) + 1]);
var diff1 = time.getTime() - now;
var diff2 = nextTime.getTime() - now;
if(now >= time.getTime() && now < nextTime.getTime()){
Logger.log(time);
}
}
var d = new Date(year, month, day, hours, minutes, seconds, milliseconds);
if you have less parameters then usevar d = new Date(year, month, day, hours, minutes);
because other formats may or may not work in all browsers. check link for reference w3schools.com/jsref/jsref_obj_date.asp