JavaScript Date Objects: Universal Coordinated Time - The GetUTCHour, Minute, Second, and Milliseconds() Function
(Page 2 of 4 )
The UTC in GetUTC stands for Universal Coordinated Time. The reason it's not UCT is a little complicated. Basically, when the system was devised in 1970, the International Telecommunication Union wanted a single abbreviation that would be used by all languages. The English speakers wanted Coordinated Universal Time (CUT) and the French speakers wanted Temps Universel Coordonné (TUC). Since they couldn't reach agreement, the ITU decided on UTC, to equally annoy both sides. And that's probably more than you really wanted to know.
Anyway, that's the way it is. In our next example we will display the UTC hours, minutes, seconds and milliseconds:
<html>
<body>
<script type="text/javascript">
var duh = new Date();
document.write("The UTC Hour is ")
document.write(duh.getUTCHours());
document.write("<br />")
document.write("The UTC Minute is ")
document.write(duh.getUTCMinutes());
document.write("<br />")
document.write("The UTC Second is ")
document.write(duh.getUTCSeconds());
document.write("<br />")
document.write("The UTC Millisecond is ")
document.write(duh.getUTCMilliseconds());
</script>
</body>
</html>
The result of this brilliant code (please, hold the applause):
The UTC Hour is 22
The UTC Minute is 41
The UTC Second is 55
The UTC Millisecond is 734
The results of this code will, of course, appear differently when you run it, unless by some bizarre coincidence you happen to run it at the same exact time as I did, down to the milliseconds.
Next: Introducing One of the Most Asinine Functions Ever >>
More JavaScript Articles
More By James Payne