Underscore.js _.now() Method

Beginner
5 min read
Updated: Nov 2026
4 examples
Utility

Definition

Returns an integer timestamp for the current time, using the fastest method available in the runtime — useful for timing and animation (official Underscore docs).

Pass the required arguments shown below. Underscore utility helpers usually return a new value or function — check edge cases before you ship.

Syntax

Call _.now. Start with this line.

Underscore
_.now()
CallWhat it does
_.now()Primary signature.
_.now(...)Call with the arguments your case needs.

Load Underscore with import _ from "underscore" (or the UMD CDN build) so these helpers are available as _.

Library declarations
Underscore
_.now()

Parameters

This method has no parameters beyond those shown in the signature.

Return Value

Return ValueDescription
*Integer milliseconds since epoch

Underscore.js Examples

Example 1 — Official Current Stamp

Call _.now() with no arguments. You get an integer of milliseconds.

Underscore
_.now();
// → 1392066795351  (docs sample)
// → live: current ms since epoch

typeof _.now();
// → "number"
Try It Yourself

How It Works

  1. Call with no args. _.now() reads the clock once.
  2. Docs sample. 1392066795351 is a fixed snapshot from the docs era.
  3. Live value. Your run prints today’s milliseconds since the epoch.
  4. Type. The return is a number, not a Date.

Example 2 — Measure Elapsed Time

Stamp before and after work; subtract to get milliseconds spent.

Underscore
var start = _.now();

// simulate work
var sum = 0;
for (var i = 0; i < 100000; i++) sum += i;

var elapsed = _.now() - start;
// → a small integer (ms)

elapsed >= 0;
// → true
Try It Yourself

How It Works

  1. Capture start. Store _.now() before the work.
  2. Do the work. Loop or any operation you care about.
  3. Subtract. _.now() - start is elapsed milliseconds.
  4. Non-negative. Clock moved forward (or stayed same within 1 ms).

Example 3 — Match Date.now()

In modern engines Underscore aliases Date.now, so the values align.

Underscore
var a = _.now();
var b = Date.now();

Math.abs(a - b) <= 1;
// → true  (same clock, ±1 ms)

typeof a === "number" && typeof b === "number";
// → true
Try It Yourself

How It Works

  1. Two stamps. Call Underscore and native Date.now.
  2. Same clock. Difference is 0 or 1 ms at most.
  3. Source. Underscore uses Date.now when it exists.
  4. Fallback. Very old engines use new Date().getTime().

Example 4 — Convert to Date / ISO

Need a Date object or ISO string? Wrap the number.

Underscore
var t = _.now();
var d = new Date(t);

d instanceof Date;
// → true

typeof d.toISOString();
// → "string"
Try It Yourself

How It Works

  1. Stamp first. _.now() gives milliseconds.
  2. Wrap. new Date(t) builds a Date from that number.
  3. ISO. toISOString() formats UTC as a string.
  4. Rule. Keep the number for storage; convert only when you need Date APIs.

Browser & Runtime Support

_.now ships with Underscore.js (1.6.0+). It runs anywhere Underscore runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install underscore. On modern engines it is Date.now.

✓ Stable · Underscore 1.6+

_.now()

Available in [email protected] (UMD / ESM). Works in evergreen browsers and current Node LTS when Underscore is loaded.

100% With Underscore 1.6+
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
_.now Underscore 1.6+

Bottom line: Safe for production once Underscore is on the page or in your bundle. Not a separate browser API — load Underscore first (or use Date.now directly). Prefer a pinned CDN version (e.g. [email protected]).

Frequently Asked Questions

_.now() returns an integer timestamp for the current time, using the fastest method available in the runtime. In modern engines that is Date.now(); otherwise it uses new Date().getTime(). The official sample is 1392066795351.
_.now() with no arguments. The docs show => 1392066795351, a sample from around February 2014 when the helper shipped. A live call prints the current milliseconds since 1970-01-01 UTC.
In current browsers and Node, yes: the source is Date.now || function(){ return new Date().getTime(); }. The number you get matches Date.now() within a millisecond or two.
Use _.now() (or Date.now()) for wall-clock stamps such as createdAt. Use performance.now() for short benchmarks: it is monotonic and higher resolution, and it counts from page load, not from 1970.
No. It returns a number (milliseconds). Wrap it with new Date(_.now()) if you need a Date object.
No. It is a stable Underscore utility added in version 1.6.0 as an optimized timestamp, used internally to speed up debounce and throttle.

Next: _.template()

Learn how Underscore compiles string templates into reusable functions.

_.template() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful