DateHelper class
Constructors
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 -
Adds
daysto date. -
currentTimestamp(
) → int - Returns current timestamp (in seconds).
-
custom(
DateTime date, String format) → String - Converts a date to a custom format.
-
endOfDay(
DateTime date) → DateTime - Returns end of day (23:59:59.999)
-
fromTimestamp(
int timestamp) → DateTime - Parses from Unix timestamp.
-
isFuture(
DateTime date) → bool - Checks if date is in the future.
-
isPast(
DateTime date) → bool - Checks if date is in the past.
-
isToday(
DateTime date) → bool - Checks if date is today.
-
isYesterday(
DateTime date) → bool - Checks if date is yesterday.
-
localized(
DateTime date, String locale, {String pattern = 'yMMMMd'}) → String - Format localized (requires Intl locale setup).
-
now(
) → DateTime - Returns the current time.
-
parse(
String? value) → DateTime? -
Parses a string into DateTime. Returns
nullif invalid. -
startOfDay(
DateTime date) → DateTime - Returns beginning of day (00:00:00)
-
subtractDays(
DateTime date, int days) → DateTime -
Subtracts
daysfrom date. -
timeAgo(
DateTime from, {DateTime? to}) → String -
Returns difference between
fromandtoas human readable string. -
toDatabase(
DateTime? date) → String? -
Formats a DateTime object into
yyyy-MM-dd HH:mm:ssfor database storage. -
toResponse(
DateTime? date) → String? - Formats a DateTime object into ISO 8601 for API response.