javascript - Uncaught TypeError: undefined is not a function -
I am trying to find the difference between 2 dates in whole months, I have a small script on the stack exchange Found, but this is giving me an error of "Uncheck Type error: there is no undefined function".
I get in Chrome, this is a fairly simple HTML page.
It does not look like the first line of the function (var monthsLeft = to.getMonth () etc ...)
(slightly simplified version for clarity :)
& lt; Script & gt; Function monthDiff (from, from) {var monthsLeft = to.getMonth () - to getMonth () + (12 * (to.getFullYear () - to.getfulair ())); If (to.getDate () & lt; from.getDate ()) {monthsLeft--; } Months of return; } Function lumpChange () {var today = new date (); Var april5th = new date (); Var months length = 0; Today = '10 / 05/2015 '; April5th = '04 / 05/2015 '; Month length = monthdays (today, April 5th); } & Lt; / Script & gt;
Your monthDiff ()
function looks like it Expected to pass the code as the date
object (it uses methods like .getMonth ()
etc.) You are passing strings.
You do not modify the date
objects by defining the strings on the variable in the original form.
function lampled change () {var today = new date (2015, 10, 05), when you install it date April5th = new date (2015, 04, 05); Month length = monthdays (today, April 5th); // -6}
If you want to set the date / time of a date
object after you turn it on
Documentation:
Comments
Post a Comment