A nice javascript time output. The javascript should be put between <head> and </head> tags.
function number(x) {
var hours = new Array("", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve");
return hours[x];
}
function ishtime(h, m) {
h = number(h)
var minutes = new Array("o'clock", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen", "twenty", "twenty-one", "twenty-two", "twenty-three", "twenty-four", "twenty-five", "twenty-six", "twenty-seven", "twenty-eight", "twenty-nine", "half", "twenty-nine", "twenty-eight", "twenty-seven", "twenty-six", "twenty-five", "twenty-four", "twenty-three", "twenty-two", "twenty-one", "twenty", "nineteen", "eighteen", "seventeen", "sixteen", "fifteen", "fourteen", "thirteen", "twelve", "eleven", "ten", "nine", "eight", "seven", "six", "five", "four", "three", "two", "one");
var time = "past";
if (m > 30)
time = "to";
if (m == 0)
return h + ' ' + minutes[0];
else
return minutes[m] + ' ' + time + ' ' + h;
}
function daytime(h) {
if (!h || h > 21)
return " at night";
if (h < 12)
return " in the morning";
if (h <= 17)
return " in the afternoon";
return " in the evening";
}
function ish(h, m) {
if (!h && !m)
{
time = new Date()
h = time.getHours()
m = time.getMinutes()
}
z = daytime(h);
h = h % 12
if (m > 57 && time.getSeconds() > 30)
m++;
if (m > 60)
m = 0;
if (m > 33)
h++;
if (h > 12)
h = 1;
if (h == 0)
h = 12;
return "It's now " + ishtime(h, m) + z + ".";
}
Then, put this HTML code to location where you want the pretty time to appear.
<script type="text/javascript">document.writeln(ish());</script>