DateTimeExtension extension

Extensions on DateTime for common date manipulations.

on

Properties

isInFuture bool

Available on DateTime, provided by the DateTimeExtension extension

Returns true when this date is after the current moment.
no setter
isInPast bool

Available on DateTime, provided by the DateTimeExtension extension

Returns true when this date is before the current moment.
no setter

Methods

addDays(int amount) DateTime

Available on DateTime, provided by the DateTimeExtension extension

Adds amount days while preserving the time components.
addHours(int amount) DateTime

Available on DateTime, provided by the DateTimeExtension extension

Adds amount hours while preserving the other components.
asUtc() DateTime

Available on DateTime, provided by the DateTimeExtension extension

Builds a UTC DateTime using this date's components.
countDays([DateTime? differenceDateTime]) int

Available on DateTime, provided by the DateTimeExtension extension

Returns elapsed days between this date and differenceDateTime.
countHours([DateTime? differenceDateTime]) int

Available on DateTime, provided by the DateTimeExtension extension

Returns elapsed hours between this date and differenceDateTime.
countMinutes([DateTime? differenceDateTime]) int

Available on DateTime, provided by the DateTimeExtension extension

Returns elapsed minutes between this date and differenceDateTime.
countMonths([DateTime? differenceDateTime]) int

Available on DateTime, provided by the DateTimeExtension extension

Returns elapsed months between this date and differenceDateTime.
countSeconds([DateTime? differenceDateTime]) int

Available on DateTime, provided by the DateTimeExtension extension

Returns elapsed seconds between this date and differenceDateTime.
countWeeks([DateTime? differenceDateTime]) int

Available on DateTime, provided by the DateTimeExtension extension

Returns elapsed weeks between this date and differenceDateTime.
countYears([DateTime? differenceDateTime]) int

Available on DateTime, provided by the DateTimeExtension extension

Returns elapsed years between this date and differenceDateTime.
currentTimeStamp() int

Available on DateTime, provided by the DateTimeExtension extension

Returns this date as a Unix timestamp in seconds.
dayOfYear() int

Available on DateTime, provided by the DateTimeExtension extension

Returns the day of the year (1 for January 1st, 365/366 for December 31st).
endOfDay() DateTime

Available on DateTime, provided by the DateTimeExtension extension

Create a new date setting hour to 23, minute to 59, and second to 59.
firstDayOfMonth() DateTime

Available on DateTime, provided by the DateTimeExtension extension

Create a new first date of this month.
firstDayOfWeek() DateTime

Available on DateTime, provided by the DateTimeExtension extension

Create a new first date of this week.
isFirstDayOfMonth() bool

Available on DateTime, provided by the DateTimeExtension extension

Returns true when this date is the first day of its month.
isLastDayOfMonth() bool

Available on DateTime, provided by the DateTimeExtension extension

Returns true when this date is the last day of its month.
isoWeekOfYear() int

Available on DateTime, provided by the DateTimeExtension extension

Returns the ISO 8601 week number of the year.
isSameWeek(DateTime other) bool

Available on DateTime, provided by the DateTimeExtension extension

Returns true when other falls in the same ISO week as this date.
isToday() bool

Available on DateTime, provided by the DateTimeExtension extension

Returns true when this date falls on today (local calendar day).
isTomorrow() bool

Available on DateTime, provided by the DateTimeExtension extension

Returns true when this date falls on tomorrow (local calendar day).
isYesterday() bool

Available on DateTime, provided by the DateTimeExtension extension

Returns true when this date falls on yesterday (local calendar day).
lastDayOfMonth() DateTime

Available on DateTime, provided by the DateTimeExtension extension

Create a new last date of this month.
lastDayOfWeek() DateTime

Available on DateTime, provided by the DateTimeExtension extension

Create a new last date of this week.
monthName({bool isHalfName = false}) String

Available on DateTime, provided by the DateTimeExtension extension

Returns the month name for this date.
nextMonth() DateTime

Available on DateTime, provided by the DateTimeExtension extension

Create a new date with next month values.
nextWeek() DateTime

Available on DateTime, provided by the DateTimeExtension extension

Create a new date with next week values.
nextYear() DateTime

Available on DateTime, provided by the DateTimeExtension extension

Create a new date with next year values.
onlyDate() DateTime

Available on DateTime, provided by the DateTimeExtension extension

Create a new date with only date value (0 for hour, minute and second).
onlyTime() DateTime

Available on DateTime, provided by the DateTimeExtension extension

Create a new date with only time value (0 for year, month and day).
previousMonth() DateTime

Available on DateTime, provided by the DateTimeExtension extension

Create a new date with previous month values.
previousWeek() DateTime

Available on DateTime, provided by the DateTimeExtension extension

Create a new date with previous week values.
previousYear() DateTime

Available on DateTime, provided by the DateTimeExtension extension

Create a new date with previous year values.
startOfDay() DateTime

Available on DateTime, provided by the DateTimeExtension extension

Create a new date setting hour, minute and second to 0.
timeZoneOffSet() String

Available on DateTime, provided by the DateTimeExtension extension

Returns the timezone offset formatted as ±HH:mm (e.g. +05:30).
tomorrow() DateTime

Available on DateTime, provided by the DateTimeExtension extension

Create a new date with tomorrow values.
toTimeAmPm() String

Available on DateTime, provided by the DateTimeExtension extension

Returns the time in 12-hour AM/PM format (e.g. "02:30 Pm").
weekdayName({bool isHalfName = false}) String

Available on DateTime, provided by the DateTimeExtension extension

Returns the weekday name for this date.
weekOfYear() int

Available on DateTime, provided by the DateTimeExtension extension

Returns the week number of the year, counting from January 1st.
yesterday() DateTime

Available on DateTime, provided by the DateTimeExtension extension

Create a new date with yesterday values.