JavaScript get current date and time: new Date, UTC fields, and strings

javascript get current date, js get date, get current date javascript, javascript current date, javascript get date, js get current date, get date javascript, current date javascript, javascript datetime now: new Date(), UTC vs local getters, ISO and locale strings.

Published

Updated

Read time 5 min read

Reviewed byDeepak Prasad

JavaScript get current date and time: new Date, UTC fields, and strings

People phrase the same need many ways: javascript get current date, get current date javascript, js get current date, javascript current date, javascript get date, or js get date. For javascript datetime now, the usual entry point is new Date() with no arguments, which captures the current instant on the host clock. From that value you can read numeric fields (getFullYear, getMonth, getDate, and their getUTC* counterparts), millisecond timestamps with getTime(), ISO strings with toISOString(), or human-facing text with toLocaleDateString and Intl.DateTimeFormat.

The snippets below use one fixed instant—2026-06-10T12:30:45.000Z—so the sample output stays identical every time you run the examples. In your own code you would call new Date() without arguments when you need the live clock; the methods are the same, only the values change. For epoch milliseconds and Unix seconds, see JavaScript timestamp: get, generate, and convert epoch time. For comparisons and ordering, see JavaScript date comparison.

Tested on: Node.js v20.18.2. A short note after each runnable snippet describes what you should see in the console.


new Date() for the current instant

Calling new Date() with no arguments produces a Date representing “now.” That is what most guides mean by javascript datetime now or get current date js at the object level—you get both date and time in a single value.

For reproducible documentation, the examples use an explicit UTC instant:

javascript
const d = new Date(Date.UTC(2026, 5, 10, 12, 30, 45, 0));
Output

Date.UTC builds the same moment you could get from new Date(2026, 5, 10, ...) in a UTC environment; here it avoids tying the article to your laptop’s local time zone.


UTC year, month, and day

When you need a calendar view that does not depend on the host’s default time zone, use the getUTC* getters. Months are still 0-based, so add one when displaying June as 6:

javascript
const d = new Date(Date.UTC(2026, 5, 10, 12, 30, 45, 0));
console.log(d.getUTCFullYear());
console.log(d.getUTCMonth() + 1);
console.log(d.getUTCDate());
Output

You should see 3 lines, in order: 2026, 6, 10.


Local getFullYear, getMonth, and getDate

For get current date javascript in the user’s or server’s local calendar, call getFullYear(), getMonth(), and getDate() on your Date. They interpret the same instant in the host time zone, so they can disagree with the getUTC* trio around midnight or across zones. Remember getMonth() returns 0 for January through 11 for December.


Milliseconds with getTime()

getTime() returns the numeric UTC milliseconds since 1 January 1970 UTC, which is handy for logging and APIs:

javascript
const d = new Date(Date.UTC(2026, 5, 10, 12, 30, 45, 0));
console.log(d.getTime());
Output

You should see one line logging 1781094645000.


A fixed-width YYYY-MM-DD in UTC

A simple way to emit an ISO-style calendar date in UTC is to combine UTC getters with padStart:

javascript
const d = new Date(Date.UTC(2026, 5, 10, 12, 30, 45, 0));
const y = d.getUTCFullYear();
const mo = String(d.getUTCMonth() + 1).padStart(2, "0");
const day = String(d.getUTCDate()).padStart(2, "0");
console.log(`${y}-${mo}-${day}`);
Output

You should see one line logging 2026-06-10.


ISO strings: toISOString() and toJSON()

Both methods yield a normalized UTC string suitable for JSON and backends. toJSON() is specified to behave like toISOString() for Date instances:

javascript
const d = new Date(Date.UTC(2026, 5, 10, 12, 30, 45, 0));
console.log(d.toISOString());
console.log(d.toJSON());
Output

You should see 2 lines, in order: 2026-06-10T12:30:45.000Z, 2026-06-10T12:30:45.000Z.


Locale output with a pinned time zone

Bare toLocaleDateString() depends on the runtime default locale and zone. Pass timeZone: "UTC" (or any IANA name you support) so readers in different regions still see the intended example:

javascript
const d = new Date(Date.UTC(2026, 5, 10, 12, 30, 45, 0));
console.log(d.toLocaleDateString("en-US", { timeZone: "UTC" }));
Output

You should see one line logging 6/10/2026.

For richer labels, Intl.DateTimeFormat keeps the same instant but controls weekday, month length, and clock fields—still with an explicit zone:

javascript
const d = new Date(Date.UTC(2026, 5, 10, 12, 30, 45, 0));
const formatter = new Intl.DateTimeFormat("en-US", {
  weekday: "long",
  year: "numeric",
  month: "long",
  day: "numeric",
  hour: "numeric",
  minute: "numeric",
  second: "numeric",
  timeZone: "America/New_York",
});
console.log(formatter.format(d));
Output

You should see one line logging Wednesday, June 10, 2026 at 8:30:45 AM.

For deeper patterns—dateStyle / timeStyle, formatToParts, and common errors—see JavaScript date formatting with Intl.DateTimeFormat.


Date.now() and new Date().getTime() stay aligned

For the live clock, Date.now() returns the same millisecond value you would read from new Date().getTime() in the same turn of the event loop:

javascript
console.log(Math.abs(Date.now() - new Date().getTime()) < 100);
Output

You should see one line logging true.


Summary

Getting the current date in javascript is usually a choice between new Date() for a rich instance API versus Date.now() when you only need epoch milliseconds. Readers ask how to format for a locale or time zone—combine the instance with Intl.DateTimeFormat or helpers from date formatting in JavaScript, and remember that Date objects are always an instant in UTC internally even when you print local strings.

Another FAQ is how to compare or sort dates safely; once you have numeric milliseconds, comparisons behave like ordinary numbers, but you should still normalize user input strings through Date.parse or explicit parsers. For epoch utilities and conversions, pair this page with JavaScript generate timestamp and JavaScript date comparison.


References

Olorunfemi Akinlua

Boasting over five years of experience in JavaScript, specializing in technical content writing and UX design. With a keen focus on programming languages, he crafts compelling content and designs …