When creating a Date object based on the computer's (not web server's!) internal clock, it is important to note that if someone's clock is off by a few hours or they are in a different time zone, then the Date object will create a different times from the one created on your own computer.To warm up our Java Script Date object skills, let's do something easy.If you do not supply any arguments to the Date constructor (this makes the Date object) then it will create a Date object based on the visitor's internal clock. That's because we still don't know the methods of the Date object that let us get the information we need (i.e. The Date object has been created, and now we have a variable that holds the current date!To get the information we need to print out, we have to utilize some or all of the following functions: Notice that we added 1 to the month variable to correct the problem with January being 0 and December being 11.
After adding 1, January will be 1, and December will be 12.Now, instead of displaying the date we, will display the format you might see on a typical digital clock -- HH: MM AM/PM (H = Hour, M = Minute).Above, we check to see if either the hours or minutes variable is less than 10.If it is, then we need to add a zero to the beginning of minutes.This is not necessary, but if it is AM, our clock would output "1:1 AM", which doesn't look very nice at all!The Junghans manufacturing company has made it possible for you to carry the most accurate clock in the United States on your wrist every day.