JavaScript: The Definitive Guide

Previous Chapter 21
JavaScript Reference
Next
 

Date.parse() Function

Name

Date.parse() Function---parse a date/time string

Availability

Navigator 2.0, Internet Explorer 3.0

Synopsis

Date.parse(date)

Arguments

date

A string containing the date and time to be parsed.

Returns

The number of milliseconds between the specified date and time and midnight, January 1st, 1970, GMT.

Description

Date.parse() is a function with a name that begins with "Date". It is related to the Date object, but it is not a method of the Date object, and is not invoked on a Date object. It is always invoked as Date.parse(), not as date.parse() on some Date object date.

Date.parse() takes a single string argument. It parses the date contained in this string and returns it in millisecond format, which can be used directly, or used to create a new Date object, or to set the date in an existing Date object with Date.setTime().

Date.parse() understands the IETF standard date format used in email and other Internet communications. Dates in this format look like this:

Wed, 8 May 1996 17:41:46 -0400

This is the format written by the Date.toGMTString() method. Date.parse() can also parse dates in this format from which the day of the week, the time zone, the seconds or the complete time specification have been omitted. It also understands the GMT time zone, and the standard abbreviations for the time zones of the United States.

Bugs

In Navigator 2.0, prior to 2.0.2, this function cannot correctly parse time zone information.

See Also

"Date", "Date.setTime()", "Date.toGMTString()", "Date.UTC()"


Previous Home Next
Date.getYear() Book Index Date.prototype

HTML: The Definitive Guide CGI Programming JavaScript: The Definitive Guide Programming Perl WebMaster in a Nutshell
This HTML Help has been published using the chm2web software.