Q:

calculate how many seconds between page load and first minute of next hour

I need to calculate a difference between two time using javascript:
now is the moment when you load the page so I use:
now = new(Date).getMinutes()*60;

then is the first minute of the next hour. So for example now is 20:20 where I live: then will be 21:01.
then my logic will be:
if(then-now>=120){
    diff=120;
}else{
    diff=then-now;
}

When I calculate the difference I need to include all the first minute of next hour.
What can be the smartest way to calculate then in seconds? 

A:

then = Date(year, month, day, new(Date).getHours()+1, 1, 0, 0);
that gives you the date object, so just do then - now into seconds (getSeconds). You should watch for 25 hours in your +1 so you could actually use: 
then.setDate(someDate.getHour() + 1); 
Also looks like your logic could just be min(diff, 120). Note that you may want to be more clear what unit 120 is in. Could even make a variable "twoMinutes=120" or "twoHours=120".
See: How to add number of days to today's date?
=== Update:
Perhaps this code makes more sense
then = Date(year, month, day, new(Date).getHours(), 0, 0, 0);
then.setDate(then.getHour() + 1);
then.setDate(then.getMinute() +1);
YourLogic = min(then-now, 120)

