DateTimeExtensions extension

Helpers for working with DateTime values.

Day-based helpers use the calendar, not 24-hour blocks, so they stay correct across daylight saving changes. UTC values stay UTC.

final now = DateTime.now();
now.startOfDay;          // today at 00:00
now.addMonths(1);        // same day next month
now.toDateString();      // '2026-11-09'
someDate.timeAgo();      // '3 hours ago'
on

Properties

daysInMonth → int

Available on DateTime, provided by the DateTimeExtensions extension

How many days this month has.
no setter
endOfDay → DateTime

Available on DateTime, provided by the DateTimeExtensions extension

The last microsecond of this day (23:59:59.999999).
no setter
endOfMonth → DateTime

Available on DateTime, provided by the DateTimeExtensions extension

The last microsecond of the last day of this month.
no setter
endOfYear → DateTime

Available on DateTime, provided by the DateTimeExtensions extension

The last microsecond of the 31st of December of this year.
no setter
isFuture → bool

Available on DateTime, provided by the DateTimeExtensions extension

Whether this moment has not happened yet.
no setter
isLeapYear → bool

Available on DateTime, provided by the DateTimeExtensions extension

Whether this date falls in a leap year.
no setter
isPast → bool

Available on DateTime, provided by the DateTimeExtensions extension

Whether this moment has already happened.
no setter
isToday → bool

Available on DateTime, provided by the DateTimeExtensions extension

Whether this date is today.
no setter
isTomorrow → bool

Available on DateTime, provided by the DateTimeExtensions extension

Whether this date is tomorrow.
no setter
isWeekday → bool

Available on DateTime, provided by the DateTimeExtensions extension

Whether this date is Monday to Friday.
no setter
isWeekend → bool

Available on DateTime, provided by the DateTimeExtensions extension

Whether this date is a Saturday or Sunday.
no setter
isYesterday → bool

Available on DateTime, provided by the DateTimeExtensions extension

Whether this date was yesterday.
no setter
startOfDay → DateTime

Available on DateTime, provided by the DateTimeExtensions extension

Midnight at the start of this day.
no setter
startOfMonth → DateTime

Available on DateTime, provided by the DateTimeExtensions extension

Midnight on the first day of this month.
no setter
startOfYear → DateTime

Available on DateTime, provided by the DateTimeExtensions extension

Midnight on the 1st of January of this year.
no setter

Methods

addDays(int days) → DateTime

Available on DateTime, provided by the DateTimeExtensions extension

Moves this date by days calendar days, keeping the time of day.
addMonths(int months) → DateTime

Available on DateTime, provided by the DateTimeExtensions extension

Moves this date by months calendar months.
addYears(int years) → DateTime

Available on DateTime, provided by the DateTimeExtensions extension

Moves this date by years calendar years.
isSameDay(DateTime other) → bool

Available on DateTime, provided by the DateTimeExtensions extension

Whether this falls on the same calendar day as other.
isSameMonth(DateTime other) → bool

Available on DateTime, provided by the DateTimeExtensions extension

Whether this falls in the same month and year as other.
monthName({bool short = false}) → String

Available on DateTime, provided by the DateTimeExtensions extension

The full name of this date's month, like November.
timeAgo({DateTime? from}) → String

Available on DateTime, provided by the DateTimeExtensions extension

Describes how long ago (or how far ahead) this is, like 3 hours ago.
toDateString() → String

Available on DateTime, provided by the DateTimeExtensions extension

The date as yyyy-MM-dd, like 2026-11-09.
toMoment() → Moment

Available on DateTime, provided by the DateTimeExtensions extension

Turns this into a Moment for richer formatting.
toTimeString() → String

Available on DateTime, provided by the DateTimeExtensions extension

The time as HH:mm:ss, like 14:05:09.
weekdayName({bool short = false}) → String

Available on DateTime, provided by the DateTimeExtensions extension

The full name of this date's weekday, like Monday.
yearsSince({DateTime? on}) → int

Available on DateTime, provided by the DateTimeExtensions extension

How many whole years have passed since this date.