PDA

View Full Version : Time of day outputs


CyberGuru
01-12-2001, 07:17 AM
I need a script that will display a different message depending on the time of day. Between midnight and noon, it should say "Good Morning", from noon til 6pm, it should say "Good Afternoon" and from 6pm until midnight, it should say "Good Evening.

Thanx~Matt

Jacob
01-12-2001, 08:28 AM
Here ya go:

<BLOCKQUOTE><font size="1" face="Verdana, Arial">code:</font><HR><pre>
&lt;SCRIPT LANGUAGE="Javascript"&gt;
&lt;!--
{
helixtime = new Date()
hrstime = helixtime.getHours()
if (hrstime &gt; 0 && hrstime &lt;12){timemsg = "Good morning."}
if (hrstime &gt; 12 && hrstime &lt;18){timemsg = "Good afternoon."}
if (hrstime &gt;18 && hrstime &lt;24){timemsg = "Good evening."}
document.write(timemsg)
}
// --&gt;
&lt;/SCRIPT&gt;
[/code]

(I modified the script per your specifications)

------------------
Jacob A. Wheeler
Co-Founder / Web Engineer
Big Resources Network
jacob@bigresources.com
ICQ: 390147 (http://www.icq.com/390147)


[This message has been edited by Jacob (edited 01-12-2001).]

CyberGuru
01-13-2001, 02:49 AM
Thanks