Reputation:
I need to verify is var is valid datetime object. This
alert( "dat::"+( typeof dat ))
returns "object". Which is the valid way ?
Upvotes: 0
Views: 72
Reputation: 4474
Here is how I would do it:
if ( Object.prototype.toString.call(d) === "[object Date]" ) {
// it is a date
}
else {
// not a date
}
Upvotes: 2