PP.isDate

Syntax

isDate(v: Date);

Parameters

v. Initial value. Optional parameter. The current date is used if this parameter is omitted.

Description

The isDate method checks if the specified value is a date.

Comments

This method returns True if the specified value is a date, otherwise it returns False.

Example

To execute the example, add a link to PP.js scenario file to HTML page. Get the current date, set to zero hours, minutes and seconds in this date:

// Get current date
var date = new Date();
console.log("Current date: " + PP.Date.format(date, "Y-m-d H:i:s"));
if (PP.isDate(date)) {
    date.setHours(0, 0, 0, 0);
    console.log("Date as of start of day: " + PP.Date.format(date, "Y-m-d H:i:s"));
} else {
    throw PP.Exception("Incorrect date object");
};

After executing the example the browser console displays the current date and date at the beginning of the day:

Current date: 2013-01-25 11:58:02
Date at the beginning of the day: 2013-01-25 00:00:00

See also:

PP