I am trying to fetch data from a db every 10 mins where the data is inserted with a timestamp. Now using this timestamp i want to visualize another field. The visualization has a step size of 10 mins. So it checks from the start till the stop time to find any match. Here is the code -

while((i += step) < stop) {
    var key = (new Date(i)).getTime();
    var value = key in lookup ? lookup[key].gtse: null;
callback(null, values);
My problem is that the timestamp which is fetched from DB never matches. Here is some data to make it clear.

The key values - 
    1st iteration - 1372168200000 
    2nd iteration - 1372168800000 
The database fetched value - 1372786393088
So in this case the key never matches when it is iterating over lookup. If i dont use step and change the while loop to while((i += 1) < stop) then the browser hangs since there is lot of processing after this.

Should i manipulate the date before db insertion and change the trailing 5-6 places to zero or should i handle this on the client side?

I need some advice how to tackle this.