JavaScript Date UTC() Method

Beginner
⏱️ 9 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Static UTC builder

What You’ll Learn

Date.UTC() is a static method that builds epoch milliseconds from UTC calendar parts—year, month, day, hour, and so on. Wrap the result in new Date(...) for a Date object, then verify with toISOString().

01

Static

Date.UTC()

02

Returns ms

Epoch number

03

Month 0

Jan = 0

04

UTC parts

Not local

05

new Date

Wrap ms

06

Compare

vs local ctor

Introduction

When you write new Date(2026, 2, 15), JavaScript treats those numbers as local calendar fields. When you need a specific instant in Coordinated Universal Time regardless of the user’s timezone, Date.UTC() interprets the same-style arguments as UTC instead.

The method returns a number—milliseconds since the Unix epoch—not a Date object. Pass that number to new Date(...) or setTime(). Pair with toUTCString() and toISOString() to inspect the result.

Understanding the Date.UTC() Method

Date.UTC(year, month[, day[, hour[, minute[, second[, millisecond]]]]]) computes one UTC instant and returns its epoch milliseconds:

  • Static — call on the Date constructor, not on an instance.
  • UTC interpretation — all supplied parts are UTC, not local.
  • Zero-indexed month — 0 = January, 11 = December.
  • Defaults — omitted day becomes 1; omitted time fields become 0.
  • Overflow — out-of-range values roll over (month 13 becomes next year).
💡
Beginner Tip

March is month index 2, not 3. A common bug is passing human month numbers directly into Date.UTC() without subtracting one.

📝 Syntax

JavaScript
Date.UTC(year, month[, day[, hour[, minute[, second[, millisecond]]]]])

Parameters

  • year — four-digit year (for example, 2026).
  • month — 0–11 (0 = January).
  • day (optional) — 1–31; defaults to 1.
  • hour (optional) — 0–23; defaults to 0.
  • minute (optional) — 0–59; defaults to 0.
  • second (optional) — 0–59; defaults to 0.
  • millisecond (optional) — 0–999; defaults to 0.

Return value

  • Epoch milliseconds for the UTC date-time described by the arguments.
  • Not a Date object—wrap with new Date(Date.UTC(...)) when you need one.

⚡ Quick Reference

GoalCode
UTC ms for a date-timeDate.UTC(2026, 2, 15, 12, 0, 0)
Date object from UTC partsnew Date(Date.UTC(2026, 2, 15))
UTC midnight Jan 1Date.UTC(2026, 0)
Verify as ISOnew Date(ms).toISOString()
Local constructor (different)new Date(2026, 2, 15)
Current epoch msDate.now()

📋 Date.UTC() vs Similar Approaches

Pick the tool that matches whether your input is UTC or local.

Date.UTC()
UTC parts→ms

Build instant

new Date(y,m,d)
local parts

Local ctor

Date.now()
now ms

Current time

Date.parse()
string→ms

Parse text

Examples Gallery

Open DevTools Console (F12) or use Try-it links. UTC examples verify cleanly with toISOString().

📚 Getting Started

Build a UTC instant and wrap it in a Date object.

Example 1 — Create a Date from Date.UTC()

March 15, 2026 at 12:30:45 UTC becomes a Date verified by ISO output.

JavaScript
const ms = Date.UTC(2026, 2, 15, 12, 30, 45);
const date = new Date(ms);

console.log(ms);
console.log(date.toISOString());
// "2026-03-15T12:30:45.000Z"
Try It Yourself

How It Works

Date.UTC() returns milliseconds. new Date(ms) stores the same instant; toISOString() confirms the UTC clock values you passed in.

📈 Practical Patterns

Local vs UTC constructors, month indexing, defaults, and diffs.

Example 2 — Same Numbers, Different Instants (UTC vs Local)

Identical arguments mean different times depending on the constructor.

JavaScript
const utcDate = new Date(Date.UTC(2026, 2, 15, 12, 0, 0));
const localDate = new Date(2026, 2, 15, 12, 0, 0);

console.log(utcDate.toISOString());
console.log(localDate.toISOString());
Try It Yourself

How It Works

Local noon is not UTC noon unless your offset is zero. Use Date.UTC() when the spec says “March 15 at 12:00 UTC” regardless of where the code runs.

Example 3 — Zero-Indexed Month (March = 2)

Human month 3 is April in JavaScript—March requires index 2.

JavaScript
const march = new Date(Date.UTC(2026, 2, 1));
const april = new Date(Date.UTC(2026, 3, 1));

console.log(march.toISOString().slice(0, 10)); // "2026-03-01"
console.log(april.toISOString().slice(0, 10));  // "2026-04-01"
Try It Yourself

How It Works

Always subtract 1 from human month numbers when calling Date.UTC() or the local Date constructor.

Example 4 — Omitted Parts Default to Midnight UTC on Day 1

Year and month alone mean 00:00:00 UTC on the first day of that month.

JavaScript
const ms = Date.UTC(2026, 0); // Jan only
const date = new Date(ms);

console.log(date.toISOString());
// "2026-01-01T00:00:00.000Z"
Try It Yourself

How It Works

Skipped day defaults to 1; skipped time fields default to 0. Handy for UTC month boundaries in reports.

Example 5 — Calculate Milliseconds Between UTC Dates

Subtract epoch values built with Date.UTC() for portable diffs.

JavaScript
const start = Date.UTC(2026, 0, 1);
const end = Date.UTC(2026, 6, 1);

const diffMs = end - start;
const diffDays = diffMs / (1000 * 60 * 60 * 24);

console.log(diffMs);
console.log(diffDays); // 181 days
Try It Yourself

How It Works

Because both values are absolute UTC milliseconds, subtraction avoids local DST surprises. For calendar-month math in local time, use dedicated date libraries.

🚀 Common Use Cases

  • Tutorial examples — predictable UTC instants in docs and tests.
  • Deadline comparisons — compare now against a fixed UTC milestone.
  • Chart axes — generate UTC tick marks from numeric parts.
  • Server schedules — encode “every day at 09:00 UTC” consistently.
  • Unit tests — assert ISO output after UTC construction.
  • setTime input — pass Date.UTC(...) to move an existing Date.

🧠 How Date.UTC() Computes Epoch Milliseconds

1

Apply defaults

Missing day becomes 1; missing time fields become 0.

defaults
2

Normalize overflow

Out-of-range months or days roll forward/backward.

normalize
3

UTC instant

Engine resolves the UTC calendar clock to one instant.

UTC
4

Return ms

Epoch milliseconds are returned—wrap with new Date() if needed.

📝 Notes

  • Static method—call Date.UTC(), not date.UTC().
  • Returns a number, not a Date object.
  • Months are zero-indexed; March is 2.
  • Arguments are UTC; local constructor uses local timezone.
  • Overflow rolls (for example, month 12 becomes January next year).
  • For “now”, use Date.now() instead of Date.UTC().

Browser & Runtime Support

Date.UTC() has been available since ES1 alongside the Date constructor. It works in every JavaScript environment.

Baseline · ES1

Date.UTC()

Supported everywhere JavaScript runs — browsers, Node.js, Deno, and Bun. No polyfill required.

100% Universal API
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
Date.UTC() Universal

Bottom line: Safe everywhere. Remember zero-indexed months, UTC interpretation, and wrap with new Date().

Conclusion

Date.UTC() turns UTC calendar parts into epoch milliseconds you can store, compare, or pass to new Date(). It is the reliable builder when your spec is written in UTC rather than local time.

Next, learn valueOf() for numeric coercion of Date objects, or review toUTCString() for readable UTC text output.

💡 Best Practices

✅ Do

  • Subtract 1 from human month numbers before calling Date.UTC()
  • Wrap with new Date(Date.UTC(...)) when you need a Date instance
  • Verify results with toISOString() in tests
  • Use UTC construction for cross-timezone deadlines
  • Subtract two Date.UTC() values for portable millisecond diffs

❌ Don’t

  • Assume Date.UTC() returns a Date object
  • Pass month 3 when you mean March (use 2)
  • Mix up Date.UTC() with the local new Date(y, m, d) constructor
  • Use Date.UTC() when you only need the current time—use Date.now()
  • Forget that overflow changes month/year unexpectedly if inputs are sloppy

Key Takeaways

Knowledge Unlocked

Five things to remember about Date.UTC()

Your foundation for building UTC instants from numeric parts.

5
Core concepts
🔢 02

Returns ms

Epoch number.

Output
📅 03

Month 0

Jan = 0.

Index
🌐 04

UTC parts

Not local.

Timezone
📦 05

new Date

Wrap ms.

Object

❓ Frequently Asked Questions

A number: milliseconds since the Unix epoch (January 1, 1970 00:00:00 UTC) for the UTC date-time built from the arguments. It does not return a Date object.
Wrap it: new Date(Date.UTC(year, month, day, hour, minute, second, ms)). The Date object stores the same instant; local getters will reflect your timezone.
Yes. January is 0, February is 1, …, December is 11. March is 2, not 3.
Date.UTC() interprets all parts as UTC. new Date(year, month, …) interprets parts in local time. The same numbers often produce different instants.
Date.now() returns the current epoch milliseconds. Date.UTC() builds milliseconds for a specific UTC calendar date and time you pass in.
Omitted day defaults to 1; omitted hour, minute, second, and millisecond default to 0. So Date.UTC(2026, 0) is UTC midnight on January 1, 2026.
Did you know?

new Date(Date.UTC(2026, 2, 15)).getTime() equals Date.UTC(2026, 2, 15)—the static method and the Date instance describe the same instant once wrapped.

Continue to valueOf()

Learn how Date objects coerce to numeric epoch milliseconds.

valueOf() 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.

6 people found this page helpful