How to Write the Javascript version of JQuery's $.now() Method

How to Write the Javascript version of JQuery's $.now() Method


In jQuery the shorthand version to the Javascript getTime function is $.now(); I want to write following statement in javascript format: // Get the time when the user clicks now = $.now();

Here’s my current code so far:

function main () {
var x = setInterval(function(){

	//get current time when user clicks "Start" button
	//can also use jQuery now method....will try later hahaha

	function myFunction(){
		var d = new Date();
		var n = d.getTime();
		document.getElementById("number").innerHTML = n;


I then want to do an operation as such:

Find the distance between now and the count down time:
remaining = end - now; …now being the result of that javasript getTime function

Thanks in advance for your help!


The $.now() method is a shorthand for the number returned by the expression (new Date).getTime().

So just use that instead of jquery’s now? var now = (new Date).getTime()??

Edit: your title confused me sorry, that wasn’t your question as you’ve already done written it in plain js


“So just use that instead of jquery’s now?” Yes, correct!
And by this: var now = (new Date).getTime()??, are you suggesting the solution?


Well, that’s exactly the same as jQuery’s now function , but that is already in your code


Oh ok, so so far my javascript version of JQuery’s $.now() method is correct?
And now, how do I express this part: remaining = end - now; …what can I use to replace “now” for this equation?