Check if a date is today

Compare the UTC calendar day of a date-time with the current one.

JavaScript Version 1.0.0 · MIT · .md

check-if-a-date-is-today.js
function isToday({ dateTime, now }) { return new Date(dateTime).toISOString().slice(0, 10) === new Date(now).toISOString().slice(0, 10); }

Input & expected output

Input

{
  "dateTime": "2026-10-28T09:00:00Z",
  "now": "2026-10-28T23:59:00Z"
}

Expected output

true

The edge case

Input

{
  "dateTime": "2026-10-28T23:30:00-03:00",
  "now": "2026-10-28T12:00:00Z"
}

Expected output

false

Know the limits

  • now is an input so the result is testable; pass new Date().toISOString() in your code.
  • “Today” is the UTC day, as in the original: a local evening can already be tomorrow, as the edge case shows.

The function above is the implementation used by the lab. The lab validates JSON types and caps size before execution; include equivalent validation when accepting untrusted input in your application.

Source & maintenance

Based on Check if a date is today from the original 1loc collection by Nguyen Huu Phuoc. Copyright (c) 2020 phuoc-ng. MIT licensed.

Takes the current time as an explicit input so the result is reproducible; compares UTC days as the original did. Original MDX retained as inert source evidence.

Maintained by Oveyon. Source commit: 14b481cf60df. Read the license.

Local fixture scope · Node.js 22.23.2 · reviewed October 28, 2026. No external service is required.

Keep exploring

Type two or more characters. Try “duplicate”, “webhook” or “retry”.