Skip to content Skip to sidebar Skip to footer

Javascript Date().gettime() Is Not A Function

I'm trying to compare some Dates in javascript. For some reason, I'm getting 'Tue May 01 2012 16:43:03 GMT+0900 (JST) has no method 'getTime'' Of course, strings don't have methods

Solution 1:

Try using new keyword to instantiate a new object so instead of this

var now = Date();

try this

var now = newDate();

Solution 2:

You need to use the new operator to create a Date object.

(newDate()).getTime()

Solution 3:

This will make 'now' as variable type as date:

var now = newDate();

This will get you time from 'now':

new Date(now).getTime();

Post a Comment for "Javascript Date().gettime() Is Not A Function"