gwolff2005 Posted April 14, 2009 Share Posted April 14, 2009 Hi guys, I have this code here for a time based greeting but it just shows Good evening. Does anyone know whats wrong? Thanks in advance!! <script type="text/javascript"> /*<![CDATA[*/ function clock() { ////////////////////////////////////////////////////// //Coded by the notorious jackpf ///////////////////////////////////////////////////// //generate time var time = new Date(); var hours = time.getHours(); var minutes = time.getMinutes(); var seconds = time.getSeconds(); //add preceding 0s, if required var hours = (hours < 10 ? '0' : '')+hours; var minutes = (minutes < 10 ? '0' : '')+minutes; var seconds = (seconds < 10 ? '0' : '')+seconds; //generate formated time var time = hours+':'+minutes+':'+seconds; //get where abouts in the day it is if(hours >= 0 && hours < 12) { var greeting = 'Good Morning'; } if(hours >= 13 && hours < 18) { var greeting = 'Good Afternoon'; } else { var greeting = 'Good Evening'; } //display time document.getElementById('clock').innerHTML = time+'<br />'+greeting; } //init clock window.onload = function() { clock(); setInterval('clock()', 1000); } /*]]>*/ </script> Link to comment https://forums.phpfreaks.com/topic/153975-solved-timezone-based-greeting/ Share on other sites More sharing options...
MasterACE14 Posted April 14, 2009 Share Posted April 14, 2009 this is a PHP help forum lol The code looks fine to me. Maybe you should wait till it is morning or afternoon? then check More then likely your webhost timezone is different to your own. It may be morning or afternoon for you, but possibly evening where the server is located. Which is why it would say evening now. Link to comment https://forums.phpfreaks.com/topic/153975-solved-timezone-based-greeting/#findComment-809299 Share on other sites More sharing options...
gwolff2005 Posted April 14, 2009 Author Share Posted April 14, 2009 java takes it from the client server, but now it shows the actual one :-) thank you anyway!!! Link to comment https://forums.phpfreaks.com/topic/153975-solved-timezone-based-greeting/#findComment-809321 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.