PaulSonny
07-02-2008, 07:38 AM
Hello Everybody,
I'm currently trying to learn JavaScript from the w3schools website. I've gone through all the basics and understand pretty well. I've started going through the Js Objects tutorials and i'm currently up to the Date Object, which is where my questions come from.
You can define a Date Object with the new keyword, as shown below.
var myDate=new Date();
The tutorial says that the date object will automatically hold the current date and time as its initial value. Does this mean that the variable myDate always has the latest time, meaning does it update every second, or does it only hold the date/time that it was created and doesn't update?
My other question is about manipulatin dates. It gives you an example like below.
var myDate=new Date();
myDate.setFullYear(2010,0,14);
The date about is 14th January 2010. I'm guessing 0 is January? Is this correct, I assumed it would be 1, being the first month?
If this is correct, does this mean that February would be 1, March would be 2 and so on?
Thats it for now, i'll probably have more questions as i'm working my way through.
Thanks for any help, its much appreciated.
Kind Regards, Paul.
I'm currently trying to learn JavaScript from the w3schools website. I've gone through all the basics and understand pretty well. I've started going through the Js Objects tutorials and i'm currently up to the Date Object, which is where my questions come from.
You can define a Date Object with the new keyword, as shown below.
var myDate=new Date();
The tutorial says that the date object will automatically hold the current date and time as its initial value. Does this mean that the variable myDate always has the latest time, meaning does it update every second, or does it only hold the date/time that it was created and doesn't update?
My other question is about manipulatin dates. It gives you an example like below.
var myDate=new Date();
myDate.setFullYear(2010,0,14);
The date about is 14th January 2010. I'm guessing 0 is January? Is this correct, I assumed it would be 1, being the first month?
If this is correct, does this mean that February would be 1, March would be 2 and so on?
Thats it for now, i'll probably have more questions as i'm working my way through.
Thanks for any help, its much appreciated.
Kind Regards, Paul.