Home > is not > javascript date gettime error

Javascript Date Gettime Error

Contents

here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies

A.gettime Is Not A Function Google Chart

of this site About Us Learn more about Stack Overflow the company Business config._d.gettime is not a function Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges

Date.now Is Not A Function

Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: google charts a.gettime is not a function Sign up javascript Date().getTime() is not a function up vote 10 down vote favorite 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 I started with this code inside a callback, but it was failing at getTime() on the line that creates javascript gethours is not a function var age: for (var i = 0; i < array_of_usage_indices.length; i++) { store.get(array_of_usage_indices[i]['key'],function(may_need_gc) { if(may_need_gc) { var now = Date(); var created = Date(may_need_gc['value']); var age = now.getTime()-created.getTime(); } }) } I've pared it down so my example page is literally just this: date test This is failing in Chrome 18.0.1025.168 and Firefox 13.0. Screenshots of what I've tried: So my question: wth? Do I have to use ParseDate()? Why isn't this working? javascript date share|improve this question edited May 2 '12 at 0:04 asked May 1 '12 at 8:20 Thunder Rabbit 2,86853067 add a comment| 2 Answers 2 active oldest votes up vote 22 down vote accepted Try using new keyword to instantiate a new object so instead of this var now = Date(); try this var now = new Date(); share|improve this answer edited May 1 '12 at 8:25 Simon 30.5k22326 answered May 1 '12 at 8:24 Parv Sharma

here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of

M._d.gettime Is Not A Function

this site About Us Learn more about Stack Overflow the company Business Learn date.parse(...).gettime is not a function more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question

Javascript Gettime

x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Undefined http://stackoverflow.com/questions/10395242/javascript-date-gettime-is-not-a-function is not a function when calling getTime on new Date up vote 2 down vote favorite 1 I get "undefined is not a function" when trying to run this. What am I missing? function bench(func) { var start = new Date.getTime(); for(var i = 0; i < 10000; i++) { func(); } console.log(func, new Date.getTime() - start); } function forLoop() { var counter http://stackoverflow.com/questions/23481530/undefined-is-not-a-function-when-calling-gettime-on-new-date = 0; for(var i = 0; i < 10; i++) { counter += 1; } return counter; } bench(forLoop); javascript share|improve this question edited May 5 '14 at 21:18 cookie monster 6,74321334 asked May 5 '14 at 20:44 JimmyRare 2,4971021 On which line do you get that error? –jfriend00 May 5 '14 at 20:46 1 possible duplicate of javascript Date().getTime() is not a function –isherwood May 5 '14 at 20:47 oh my. hehe, ofc. thanks –JimmyRare May 5 '14 at 20:48 2 @isherwood - this doesn't look like a dup of that one. The solution in that case was to add use new Date() instead of just Date(). The OP here was already using new. –jfriend00 May 5 '14 at 20:50 add a comment| 2 Answers 2 active oldest votes up vote 5 down vote accepted You need to use: new Date().getTime(); instead of new Date.getTime(); Here's some explanation of what was doing on. When you do: new Date.getTime(); it looks for the getTime() property on the Date constructor and that is undefined because that property exists on the prototype or actual instan

Learn Bootstrap Learn Graphics Learn Icons Learn How To JavaScript Learn JavaScript Learn jQuery Learn jQueryMobile Learn AppML Learn AngularJS Learn JSON Learn AJAX Server Side Learn SQL Learn PHP Learn http://www.w3schools.com/jsref/jsref_gettime.asp ASP Web Building Web Templates Web Statistics Web Certificates XML Learn XML Learn XML AJAX Learn XML DOM Learn XML DTD Learn XML Schema Learn XSLT Learn XPath Learn XQuery × HTML HTML Tag Reference HTML Event Reference HTML Color Reference HTML Attribute Reference HTML Canvas Reference HTML SVG Reference Google Maps Reference CSS CSS Reference CSS Selector Reference W3.CSS Reference Bootstrap Reference Icon is not Reference JavaScript JavaScript Reference HTML DOM Reference jQuery Reference jQuery Mobile Reference AngularJS Reference XML XML Reference XML Http Reference XSLT Reference XML Schema Reference Charsets HTML Character Sets HTML ASCII HTML ANSI HTML Windows-1252 HTML ISO-8859-1 HTML Symbols HTML UTF-8 Server Side PHP Reference SQL Reference ASP Reference × HTML/CSS HTML Examples CSS Examples W3.CSS Examples Bootstrap Examples JavaScript JavaScript Examples HTML DOM Examples is not a jQuery Examples jQuery Mobile Examples AngularJS Examples AJAX Examples XML XML Examples XSLT Examples XPath Examples XML Schema Examples SVG Examples Server Side PHP Examples ASP Examples Quizzes HTML Quiz CSS Quiz JavaScript Quiz Bootstrap Quiz jQuery Quiz PHP Quiz SQL Quiz XML Quiz × JavaScript Reference Overview JavaScript JS String JS Number JS Operators JS Statements JS Math JS Date JS Array JS Boolean JS RegExp JS Global JS Conversion Browser BOM Window Navigator Screen History Location HTML DOM DOM Document DOM Elements DOM Attributes DOM Events DOM Style HTML Objects