samuel_lopez Posted March 18, 2016 Share Posted March 18, 2016 How to automatic pop up an alert when time is 12 pm using javascript. Quote Link to comment https://forums.phpfreaks.com/topic/301033-pop-up-alert-when-time-is-12pm/ Share on other sites More sharing options...
Jacques1 Posted March 18, 2016 Share Posted March 18, 2016 12 p. m. in what time zone? The user's zone? The server's zone? Some other zone? Assuming the user's local time: Get the difference in milliseconds between the target time and the current time, then set a timeout for this difference. popUpTime = new Date(); popUpTime.setHours(12); popUpTime.setMinutes(0); popUpTime.setSeconds(0); popUpTime.setMilliseconds(0); now = new Date(); setTimeout(function () { alert("Oh hai."); }, popUpTime - now); I hope you're not actually using an alert(), because that's one of the most annoying misfeatures ever invented. Quote Link to comment https://forums.phpfreaks.com/topic/301033-pop-up-alert-when-time-is-12pm/#findComment-1532157 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.