Excitus Posted January 31, 2008 Share Posted January 31, 2008 I need the text to appear from 16:30 to 8:30 the next days. Thats all I have worked out but the time is inv3erted and Im missing minutes... <html> <head> </head> <body> <script> var curdate = new Date(); if (curdate.getHours() >= 8 && curdate.getHours() < 20) alert('You reporting after hours, please call this number 555-555-5555, then submit the incendent report'); </script> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/88659-time-sensitive/ Share on other sites More sharing options...
kenrbnsn Posted January 31, 2008 Share Posted January 31, 2008 This looks like Javascript, therefore I'm moving it from the PHP area to the Javascript area. Ken Quote Link to comment https://forums.phpfreaks.com/topic/88659-time-sensitive/#findComment-454028 Share on other sites More sharing options...
phpQuestioner Posted January 31, 2008 Share Posted January 31, 2008 You just needed to flip some stuff around: <html> <head> </head> <body> <script> var curdate = new Date(); if (curdate.getHours() >= 8 && curdate.getHours() < 20) { // error is not given because you are open } else { alert('You reporting after hours, please call this number 555-555-5555, then submit the incendent report'); } </script> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/88659-time-sensitive/#findComment-454037 Share on other sites More sharing options...
Excitus Posted January 31, 2008 Author Share Posted January 31, 2008 That's great, what about the minutes? can something be done? Quote Link to comment https://forums.phpfreaks.com/topic/88659-time-sensitive/#findComment-454045 Share on other sites More sharing options...
phpQuestioner Posted January 31, 2008 Share Posted January 31, 2008 try this; it may not work, but check and see: <html> <head> </head> <body> <script> var curdate = new Date(); if (curdate.getHours() >= 8.5 && curdate.getHours() < 20.5) { // error is not given because you are open } else { alert('You reporting after hours, please call this number 555-555-5555, then submit the incendent report'); } </script> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/88659-time-sensitive/#findComment-454056 Share on other sites More sharing options...
Excitus Posted January 31, 2008 Author Share Posted January 31, 2008 Is it possible to not have a popup alert, but more just having a text added to the site?! Quote Link to comment https://forums.phpfreaks.com/topic/88659-time-sensitive/#findComment-454324 Share on other sites More sharing options...
obsidian Posted January 31, 2008 Share Posted January 31, 2008 Not to burst anyone's bubble, but using JavaScript for this type of display calculation requires that you are dependent upon your client time being accurately set. JavaScript pulls the system time, so if someone has their time set to one different than yours, or if they have their timezone offset differently than yours, you'll always have it show during THEIR 16:30 - 8:30. Quote Link to comment https://forums.phpfreaks.com/topic/88659-time-sensitive/#findComment-454330 Share on other sites More sharing options...
Excitus Posted January 31, 2008 Author Share Posted January 31, 2008 The time set or time zone is not really that big of an issue. What i'm more concerned about is, not having an alert (popup), but more as a text on the site shown between does hours?! Possible?? Quote Link to comment https://forums.phpfreaks.com/topic/88659-time-sensitive/#findComment-454341 Share on other sites More sharing options...
obsidian Posted January 31, 2008 Share Posted January 31, 2008 The time set or time zone is not really that big of an issue. What i'm more concerned about is, not having an alert (popup), but more as a text on the site shown between does hours?! Possible?? Don't use alert(), but rather use document.write()... or even better, put a div with an id where you want your message to show and update the content. For instance, have something like this in the page: <div id="messageDiv"></div> Then, you can access is like this: document.getElementById('messageDiv').innerHTML = "My Message!!!"; Quote Link to comment https://forums.phpfreaks.com/topic/88659-time-sensitive/#findComment-454363 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.