DateTimeFormatting extension

on

Properties

calculateAge int
The calculateAge property calculates the age of a person based on their birthdate. It takes the current date into account and returns the person's age in years.
no setter

Methods

addDays(int days) DateTime
addDays(): Adds a specified number of days to a DateTime.
addHours(int hours) DateTime
addHours(): Adds a specified number of hours to a DateTime.
addMilliseconds(int milliseconds) DateTime
addMilliseconds(): Adds a specified number of milliseconds to a DateTime.
addMinutes(int minutes) DateTime
addMinutes(): Adds a specified number of minutes to a DateTime.
addMonths(int months) DateTime
addMonths(): Adds a specified number of months to a DateTime.
addSeconds(int seconds) DateTime
addSeconds(): Adds a specified number of seconds to a DateTime.
addWeekdaysBySkippingWeekends(int daysToAdd) DateTime
addYears(int years) DateTime
addYears(): Adds a specified number of years to a DateTime.
formatDate({required String likeGiven}) String?
formatDate(): Formats a DateTime object using a specified format string. The likeGiven parameter is used to provide a format hint, and the function detects the appropriate format based on the string's contents.
subtractDays(int days) DateTime
subtractDays(): Subtracts a specified number of days from a DateTime.
subtractHours(int hours) DateTime
subtractHours(): Subtracts a specified number of hours from a DateTime.
subtractMilliseconds(int milliseconds) DateTime
subtractMilliseconds(): Subtracts a specified number of milliseconds from a DateTime.
subtractMinutes(int minutes) DateTime
subtractMinutes(): Subtracts a specified number of minutes from a DateTime.
subtractMonths(int months) DateTime
subtractMonths(): Subtracts a specified number of months from a DateTime.
subtractSeconds(int seconds) DateTime
subtractSeconds(): Subtracts a specified number of seconds from a DateTime.
subtractYears(int years) DateTime
subtractYears(): Subtracts a specified number of years from a DateTime.
to12HourTime() String
Format DateTime as 12-Hour Time with AM/PM: hh:MM:SS AM/PM
to24HourTime() String
Format DateTime as 24-Hour Time: HH:MM:SS
toIso8601() String
Format DateTime as ISO 8601
toLongDate() String
Format DateTime as Long Date: Month DD, YYYY
toShortDate() String
Format DateTime as Short Date: MM/DD/YYYY
weeksInMonth() int
weeksInMonth(): Calculates the number of weeks in the month of a DateTime.