Last active
June 26, 2023 17:08
-
-
Save RaphaelAudet/3768b7e49a12aef5c369b77dd08c1a94 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Function to calculate the number of milliseconds left until 13:00 Paris time | |
function calculateMillisecondsLeft() { | |
const now = new Date(); | |
const parisTime = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 13, 0, 0); // Set the desired time (13:00) | |
const timeUntilParisTime = parisTime - now; // Time difference until 13:00 Paris time | |
const millisecondsLeft = Math.floor(timeUntilParisTime); | |
return millisecondsLeft; | |
} | |
// Function to wait for the specified duration in milliseconds and then navigate | |
function waitForDurationAndNavigate(durationInMilliseconds) { | |
setTimeout(function() { | |
const desiredUrl = "https://example.com"; | |
window.location.href = desiredUrl; | |
}, durationInMilliseconds); | |
} | |
// Calculate the number of milliseconds left until 13:00 Paris time | |
const millisecondsLeft = calculateMillisecondsLeft(); | |
// Wait for the calculated duration and then navigate to example.com | |
waitForDurationAndNavigate(millisecondsLeft); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment