Convert Date String to Date Object Method

The Convert Date String to Date Object method converts a date string to a date object. It returns a date object that includes the date in the dateString argument.

Format

Date.parse(dateString)

The following table describes the arguments for the Convert Date String to Date Object method.

Argument Description

dateString

A string that uses the following format:

weekday, Month dd, yyyy hh:mm:ss

Usage

To call the Convert Date String to Date Object method, you use the date constructor rather than a variable. You must use the following format:

Friday, October 31, 1998 15:30:00 -0800

where:

The last number in the string is the offset from Greenwich mean time.

The following items use this format:

  • The dateVar.toGMTString method

  • Email applications

  • Internet applications

You can omit the day of the week, time zone, time specification, and seconds field. For example, consider the following code:

var aDate = Date.parse(dateString);

This code is equivalent to the following code:

var aDate = new Date(dateString);

The following example results in a value of 9098766000:

var aDate = Date.parse("Friday, October 31, 1998 15:30:00 -0220");
TheApplication().RaiseErrorText(aDate);