Javascript: Calculate time between today and a specific following weekday time

Viewed 273

I'm looking for a method to calculate the time in seconds between now UTC-7 and the following Saturday (independent of the date the calculation is being done) at a specific UTC-7 time (08:00) in Javascript.

Currently I am using this code but i want to replace giving specific dates with the abovementioned calculation:

// Grab the current date
var now = new Date();
var currentDate = new Date(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(),  now.getUTCHours(), now.getUTCMinutes(), now.getUTCSeconds()); currentDate.setHours(currentDate.getHours() - 7);

// Set some date in the future. 
var ClashDate  = new Date("August 6, 2017 16:40:00");
var BashDate  = new Date("August 12, 2017 08:00:00");

// Calculate the difference in seconds between the future and current date
var diffclash = ClashDate.getTime() / 1000 - currentDate.getTime() / 1000;
var diffbash = BashDate.getTime() / 1000 - currentDate.getTime() / 1000;

Could anyone help me out?

Yours sincerely Yamper

2 Answers
Related