please dont rip this site

JavaScript: The Definitive Guide

Previous Chapter 3
Variables and Data Types
Next
 

3.10 The Date Object

The sections above have described all of the fundamental data types supported by JavaScript. Dates and times are not one of these fundamental types. But JavaScript does provide a type (or class) of object that represents dates and times, and can be used to manipulate this type of data. A Date object in JavaScript is created with the new operator and the Date() constructor:

now =index.html new Date();   // create an object representing the current date and time
xmas =index.html new Date(96, 11, 25);  // Create a Date object representing Christmas

Methods of the Date object allow you to get and set the various date and time values, and to convert the Date to a string, using either local time or GMT time. For example:

xmas.setYear(xmas.getYear() + 1);    // Change the date to next Christmas
document.write("Today is: " + now.toLocaleString());
In addition, the Date object also defines functions (not methods; they are not invoked through a Date object) to convert a date specified in string or numeric form to an internal millisecond representation that is useful for some kinds of date arithmetic.

You can find full documentation on the Date object and its methods in the reference section of this book. Unfortunately, the Date object is plagued with various bugs in Navigator 2.0. Appendix B, Known Bugs, contains details.


Previous Home Next
Undefined Book Index Data Type Wrapper Objects

HTML: The Definitive Guide CGI Programming JavaScript: The Definitive Guide Programming Perl WebMaster in a Nutshell

file: /Techref/language/java/script/definitive/ch03_10.htm, 4KB, , updated: 2019/10/14 15:00, local time: 2024/11/22 13:25,
TOP NEW HELP FIND: 
18.222.113.135:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://ecomorder.com/techref/language/java/script/definitive/ch03_10.htm"> [Chapter 3] 3.10 The Date Object</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to ecomorder.com!

 

Welcome to ecomorder.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .