DateUtils class

Date utility functions for common date operations

Constructors

DateUtils()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

addDays(DateTime date, int days) DateTime
Add days to a date
addMonths(DateTime date, int months) DateTime
Add months to a date
addYears(DateTime date, int years) DateTime
Add years to a date
dateToString(DateTime date, {String format = 'yyyy-MM-dd'}) String
Convert DateTime to formatted string
endOfDay(DateTime date) DateTime
Get end of day (23:59:59.999)
getAge(DateTime birthDate) int
Get age from birth date
getCurrentDateTime({String format = 'yyyy-MM-dd HH:mm:ss'}) String
Get current date and time in specified format
getDateDifference(DateTime startDate, DateTime endDate, {String unit = 'days'}) int
Get difference between two dates
getDaysInMonth(int year, int month) int
Get the number of days in a month
isLeapYear(int year) bool
Check if a year is leap year
isToday(DateTime date) bool
Check if date is today
isTomorrow(DateTime date) bool
Check if date is tomorrow
isYesterday(DateTime date) bool
Check if date is yesterday
startOfDay(DateTime date) DateTime
Get start of day (00:00:00)
stringToDate(String dateString, {String format = 'yyyy-MM-dd'}) DateTime?
Convert string to DateTime object