[Solved] How do I successfully pass in a parameter in this onclick function? Uncaught ReferenceError: B081517B is not defined [duplicate]


You’d have to convert your date string to a timestamp (milliseconds since 1-1-1970). Then you could do the same to the current date and compare the two (subtracting one from another). With the difference in milliseconds, you can calculate the amount of hours by dividing it by the amount of milliseconds that are in one hour (1000*60*60 = 3600000). You’ll want to round that down, so you don’t get a long decimal number.

Here’s an example: http://jsfiddle.net/4k97au4a/1/

then = Date.parse("2015-11-20T19:56:12+0000");
now = Date.now();
var difference = now - then;
var hours = Math.floor(difference/3600000);
document.write(hours+" hours ago");

solved How do I successfully pass in a parameter in this onclick function? Uncaught ReferenceError: B081517B is not defined [duplicate]