Alex Rivera | Logout

Calculate amount of time until the next hour

Asked 2012-02-18T01:17:31.527
9

I'm working on a busing website project and the buses run every hour. I'm having trouble creating a widget that finds the time between now and the next hour, so that it is clear when the next bus will run. My client requires that it is in javascript. Any suggestions? Thanks in advance.

Edit
Report

1 Answer

0

Lots of answers, a really simple function to get the rounded minutes remaining to the next hour is:

function minsToHour() {
  return 60 - Math.round(new Date() % 3.6e6 / 6e4);
}
answered 2012-02-18T02:32:04.707

Your Answer