You will need to make changes to your code to handle time, instead of time use
timeToday(time, location.timeZone)
and it should solve your problem. See this thread: