View Single Post
Old 16-12-2007, 06:30   #32 (permalink)
Bill Posters
trouble free and loverlee
 
Join Date: Mar 2003
Location: YooKay
Posts: 2,962
Imho™…

For such a non-critical thing, javascript would be the better option.
Its date functions work according to the date on the user's machine. So, presuming the date on their machine is set correctly, it'll automatically be a localised time-based greeting.

JavaScript Date Object Reference

You could have a default greeting in the markup and use js to customise it to a localised, time-based greeting.

(rough) e.g.
Code:
window.onload = init; function init() { if (!document.getElementById('greeting')) return; var greetingEl = document.getElementById('greeting'); var d = new Date(); var hour = d.getHours(); var greetingMsg = ''; if (hour < 12) { greetingMsg = 'Good morning!'; } if (hour >= 12 && hour < 19) { greetingMsg = 'Good afternoon!'; } if (hour >= 19) { greetingMsg = 'Good evening!'; } greetingEl.firstChild.nodeValue = greetingMsg; }
Code:
<p id="greeting">Welcome!</p>
  Reply With Quote