DateTimeExtension extension

on

Properties

asUtc DateTime?
Converts the DateTime object to the UTC timezone.
no setter
currentTimeStamp int
Returns the current timestamp in seconds.
no setter
dateOnly DateTime
Returns a DateTime with the date of the original, but time set to midnight.
no setter
firstDayOfMonth DateTime
Returns a DateTime instance representing the first day of the month of this DateTime.
no setter
firstDayOfWeek DateTime
Returns a DateTime instance representing the first day of the week of this DateTime.
no setter
isFirstDayOfMonth bool
Checks if this DateTime instance represents the first day of the month.
no setter
isLastDayOfMonth bool
Checks if this DateTime instance represents the last day of the month.
no setter
isNotNull bool
Returns true if the given date is not null.
no setter
isToday bool
Returns true if the given date is today.
no setter
isTomorrow bool
Returns true if the given date is tomorrow.
no setter
isYesterday bool
Returns true if the given date is yesterday.
no setter
lastDayOfMonth DateTime
Returns a DateTime instance representing the last day of the month of this DateTime.
no setter
lastDayOfWeek DateTime
Returns a DateTime instance representing the last day of the week of this DateTime.
no setter
nextDay DateTime
Returns a DateTime representing the day after this DateTime.
no setter
nextMonth DateTime
Returns a DateTime instance representing the exact date of the next coming month.
no setter
nextWeek DateTime
Returns a DateTime instance representing the exact date of the coming week.
no setter
previousDay DateTime
Returns a DateTime representing the day before this DateTime.
no setter
previousMonth DateTime
Returns a DateTime instance representing the exact date of the previous month.
no setter
previousWeek DateTime
Returns a DateTime instance representing the exact date of the previous week.
no setter
timeAgo String?
Returns the time difference from this DateTime to the current DateTime in Indian language.
no setter
toTimeAmPm String?
Returns the time in AM/PM format for this DateTime.
no setter

Methods

addDays(int amount) DateTime
Adds a certain amount of days to this date and returns a new DateTime instance.
addHours(int amount) DateTime
Adds a certain amount of hours to this date and returns a new DateTime instance.
countDays(DateTime? differenceDateTime) int
Calculates the number of days between two DateTime objects.
countHours(DateTime? differenceDateTime) int
Calculates the difference in hours between the current DateTime object and differenceDateTime.
countMinutes(DateTime? differenceDateTime) int
Converts the time difference to a number of minutes.
countMonths(DateTime? differenceDateTime) int
Calculates the number of months between the current DateTime object and differenceDateTime.
countSeconds(DateTime? differenceDateTime) int
Converts the time difference to a number of seconds.
countWeeks(DateTime? differenceDateTime) int
Counts the number of weeks between the current DateTime and the differenceDateTime.
countYears(DateTime? differenceDateTime) int
Calculates the number of years between this DateTime instance and another DateTime instance.
isSameDay(DateTime b) bool
Checks whether two DateTime instances are on the same day.
isSameWeek(DateTime b) bool
Checks if two DateTime instances fall within the same week.
monthName({bool isHalfName = false}) String?
Returns Month name of give this DateTime Example: final date = DateTime.now(); //output: 2023-05-24 13:14:23.593304 print(date.monthName()??""); //output: May
toIndiaTimeZone() DateTime?
Converts the DateTime object to the Indian time zone.
weekdayName({bool isHalfName = false}) String?
Returns the name of the weekday for the given date.