JavaScript & jQuery Tutorials

JS Home Right Arrow JS Reference Right Arrow Date Right Arrow parse()

parse()  Date  class method

Description

Parses a string representation of a date and returns the number of milliseconds since 1 January 1970 00:00:00 UTC.

  • Date.parse() accepts time zone-offsets (GMT+230 for example).
  • Date.parse() uses local time zone if no time zone entered.
  • Date.UTC() local time defaults are applied to any arguments not supplied.
  • Like all class methods parse() should be used on the class rather than an instance of the class.

Syntax


Signature Description
Date.parse(dateString)Parses a string representation of a date and returns the number of milliseconds since 1 January 1970 00:00:00 UTC.

Parameters


Parameter Description
dateStringA string representation of a date.

Examples

The code below shows examples of the parse() method of Date.




// Parse a Date.
var cDate = new Date('Jan 1, 2000');
alert(cDate);

// Parse a Date with time zone.
var cDate = new Date('Jan 1, 2000, 12:12:12 GMT+0430');
alert(cDate);


Press the button below to action the above code:



Related Tutorials

JavaScript Intermediate Tutorials - Lesson 2 - Dates and Times




  

go to home page Homepage go to top of page Top