jQuery.now()    **DEPRECATED in Version 3.3** JQ Home  <<  Utilities  <<  jQuery.now()

Shorthand date retrieval.

Description

The jQuery.now() jQuery General utility method, is a shorthand method for getting the current time as returned by the expression (new Date).getTime().

Shorthand version $.now()

  • Returns the number of milliseconds since 1 January 1970 00:00:00 UTC. Dates prior to this will return a negative value.
  • See the Date object reference, for a full description of JavaScript dates.

This method was deprecated in jQuery 3.3.

Syntax

Signature Description
jQuery.now()Returns the number of milliseconds since 1 January 1970 00:00:00 UTC.

Parameters

None.

Return

A Number object.

jQuery.now() Example Utilities  <<  Top

Shorthand method for getting the current time.

In the example when we press the button the first time we display a message for the longhand version of the current time using (new Date).getTime() and our shorthand version using the jQuery.now() jQuery General utility method.


$(function(){
  $('#btn2').one('click', function(){
    $('#div2').append((new Date).getTime() + '<br>');
    $('#div2').append($.now() + '<br>');
  });
});

div2. Some initial text.

Press the button below to action the above code:

Related Tutorials

jQuery Intermediate Tutorials - Lesson 9 - jQuery General Utilities