Converts a properly formatted date string (e.g., 03/12/1999) into either a date object, or the numeric value corresponding to the time for the specified date according to local time.

Syntax

JSV_convertDateString(expS [, dateFormat])

Prototype

expS.convertDateString([dateFormat])

Returns

The function convertDateString returns either a date object, or the numeric value corresponding to the time for the specified date according to local time.

Parameters

The convertDateString function uses the following arguments.

Argument Description
expS A string containing a date (e.g., 03/12/1999 or 3-12-1999).
dateFormat Optional. Value that indicates whether the returned value is a date object, or the numeric value corresponding to the time for the specified date according to local time. Default is 0 which corresponds to the numeric value corresponding to the time for the specified date according to local time.

0 - Numeric value corresponding to the time for the specified date according to local time
1 - Date object (e.g., Wed Mar 31 15:58:17 CST 1999)

Remarks

JSV_convertDateString does not validate the input string. You should use JSV_fsDate to ensure a valid date is passed to this function.

Dependencies

JSV_parseString, JSV_trimL, JSV_toDate

Example

The following lines of code

var myDate = "04/15/1999";
document.write( "Numeric value: " + JSV_convertDateString(myDate) );
document.write( "Date object: " + JSV_convertDateString(myDate,1) );

produce