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 bydayscalendar days, keeping the time of day. -
addMonths(
int months) → DateTime -
Available on DateTime, provided by the DateTimeExtensions extension
Moves this date bymonthscalendar months. -
addYears(
int years) → DateTime -
Available on DateTime, provided by the DateTimeExtensions extension
Moves this date byyearscalendar years. -
isSameDay(
DateTime other) → bool -
Available on DateTime, provided by the DateTimeExtensions extension
Whether this falls on the same calendar day asother. -
isSameMonth(
DateTime other) → bool -
Available on DateTime, provided by the DateTimeExtensions extension
Whether this falls in the same month and year asother. -
monthName(
{bool short = false}) → String -
Available on DateTime, provided by the DateTimeExtensions extension
The full name of this date's month, likeNovember. -
timeAgo(
{DateTime? from}) → String -
Available on DateTime, provided by the DateTimeExtensions extension
Describes how long ago (or how far ahead) this is, like3 hours ago. -
toDateString(
) → String -
Available on DateTime, provided by the DateTimeExtensions extension
The date asyyyy-MM-dd, like2026-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 asHH:mm:ss, like14:05:09. -
weekdayName(
{bool short = false}) → String -
Available on DateTime, provided by the DateTimeExtensions extension
The full name of this date's weekday, likeMonday. -
yearsSince(
{DateTime? on}) → int -
Available on DateTime, provided by the DateTimeExtensions extension
How many whole years have passed since this date.