Aven Dyke Aven Dyke - 1 year ago 98
Javascript Question

Trying to make a clock in JavaScript, getting an error, Uncaught TypeError: undefined is not a function

Clock script is very basic, I have:

function time() {
var time = new Date().getTime();
var ms = time.substring(11, 13)
var secs = time.substring(0, 10)

When using
, it returns the error "undefined is not a function"
I need a way to get that "time" value to be set to the actual returned number, not the
new Date().GetTime();
returning it.

Answer Source

You can't use substring() because the time isn't a string. Convert it to a string first:

var time = ''+(new Date().getTime());
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download