CyrefJS
CCyrefJS
فا
Back to documentation
Date/Since 1.38.0

isAfter

Checks whether the first date occurs after the second date.

isAfter(dateLeft, dateRight):boolean

Parameters

dateLeftDaterequired

The date to compare as the first value.

dateRightDaterequired

The date to compare against.

Returns

boolean

true if dateLeft occurs after dateRight; otherwise, false.

Examples

01

Basic usage

Check whether one date is after another date.

TypeScript
import { isAfter } from "@cyref/js";

const dateLeft = new Date("2026-01-10");
const dateRight = new Date("2026-01-05");

const result = isAfter(dateLeft, dateRight);

console.log(result);
// true
02

Date is not after

Returns false when dateLeft occurs before dateRight.

TypeScript
import { isAfter } from "@cyref/js";

const dateLeft = new Date("2026-01-05");
const dateRight = new Date("2026-01-10");

const result = isAfter(dateLeft, dateRight);

console.log(result);
// false
03

Equal dates

Equal dates return false because the function checks for a strictly later date.

TypeScript
import { isAfter } from "@cyref/js";

const dateLeft = new Date("2026-03-15T12:00:00");
const dateRight = new Date("2026-03-15T12:00:00");

const result = isAfter(dateLeft, dateRight);

console.log(result);
// false
04

Time is included in the comparison

The complete timestamp is compared, including hours, minutes, seconds, and milliseconds.

TypeScript
import { isAfter } from "@cyref/js";

const dateLeft = new Date("2026-06-10T15:30:00");
const dateRight = new Date("2026-06-10T14:30:00");

const result = isAfter(dateLeft, dateRight);

console.log(result);
// true
05

Same day, different time

Two dates on the same calendar day can still produce different results based on their time.

TypeScript
import { isAfter } from "@cyref/js";

const morning = new Date("2026-08-20T09:00:00");
const evening = new Date("2026-08-20T18:00:00");

console.log(isAfter(evening, morning));
// true

console.log(isAfter(morning, evening));
// false
Built with@cyref/js·Official documentation