DateUtils class

Constructors

DateUtils.new()
factory

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

addMonths(DateTime date, int months) DateTime
Returns the DateTime resulting from adding the given number of months to this DateTime.
copyWith(DateTime date, {int? year, int? month, int? day, int? hour, int? minute, int? second, int? millisecond, int? microsecond}) DateTime
Creates a copy of date but with the given fields replaced with the new values.
firstDayOfFirstWeek(int year, {int firstWeekday = DateTime.monday}) DateTime
Returns start of the first day of the first week in year.
firstDayOfMonth(DateTime date) DateTime
Returns DateTime that represents a beginning of the first day of the month containing date.
firstDayOfNextMonth(DateTime dateTime) DateTime
Returns DateTime that represents a beginning of the first day of the next month.
firstDayOfNextWeek(DateTime dateTime, {int firstWeekday = DateTime.monday}) DateTime
Returns start of the first day of the next week for specified dateTime.
firstDayOfNextYear(DateTime dateTime) DateTime
Returns DateTime that represents a beginning of the first day of the next year.
firstDayOfWeek(DateTime dateTime, {int firstWeekday = DateTime.monday}) DateTime
Returns start of the first day of the week for specified dateTime.
firstDayOfYear(DateTime dateTime) DateTime
Returns DateTime that represents a beginning of the first day of the year containing date.
formatDate(DateTime? dateTime, {String? format}) String
format date by DateTime. format 转换格式(已提供常用格式 DateFormats,可以自定义格式:'yyyy/MM/dd HH:mm:ss') 格式要求 year -> yyyy/yy month -> MM/M day -> dd/d hour -> HH/H minute -> mm/m second -> ss/s
formatDateMs(int ms, {bool isUtc = false, String? format}) String
format date by milliseconds. 格式化日期毫秒时间
formatDateStr(String dateStr, {bool? isUtc, String? format}) String
format date by date str. dateStr 日期字符串
generateWithDayStep(DateTime start, DateTime end) Iterable<DateTime>
Returns an iterable of DateTime with 1 day step in given range.
getDateMsByTimeStr(String dateStr, {bool? isUtc}) int?
get DateMilliseconds By DateStr. 将字符串时间转化为毫秒值
getDateTime(String dateStr, {bool? isUtc}) DateTime?
get DateTime By DateStr. 将字符串时间转化为DateTime
getDateTimeByMs(int ms, {bool isUtc = false}) DateTime
get DateTime By Milliseconds. 将毫秒时间转化为DateTime
getDayNumberInWeek(DateTime date, {int firstWeekday = DateTime.monday}) int
Returns number of the day in week (starting with 1).
getDayNumberInYear(DateTime date) int
Returns number of the day in year.
getDayOfYear(DateTime dateTime) int
get day of year. 在今年的第几天.
getDayOfYearByMs(int ms, {bool isUtc = false}) int
get day of year. 在今年的第几天.
getDaysDifference(DateTime a, DateTime b) int
Returns count of days between two dates.
getDaysInMonth(int year, int monthNum) int
Returns number of days in the month of the year.
getDaysInYear(int year) int
Returns the number of days in a given year.
getLastWeekNumber(int year, {int firstWeekday = DateTime.monday}) int
Returns number of the last week in year.
getNowDateMs() int
get Now Date Milliseconds. 获取当前毫秒值
getNowDateStr() String
get Now Date Str.(yyyy-MM-dd HH:mm:ss) 获取现在日期字符串,默认是:yyyy-MM-dd HH:mm:ss
getNowDateTimeFormat(String outFormat) String
获取当前日期,返回指定格式
getNowUtcDateTime() DateTime
获取当前日期返回DateTime(utc)
getUtcDateTimeFormat(String outFormat) String
获取当前日期,返回指定格式
getWeekday(DateTime? dateTime, {String languageCode = 'en', bool short = false}) String
get WeekDay. dateTime isUtc languageCode zh or en short
getWeekdayByMs(int milliseconds, {bool isUtc = false, String languageCode = 'en', bool short = false}) String
get WeekDay By Milliseconds. 获取毫秒值对应是星期几
getWeekNumber(DateTime date, {int firstWeekday = DateTime.monday}) int
Returns week number in year.
getYesterday() DateTime
获取昨天日期返回DateTime
isCurrentDate(DateTime date) bool
Проверяет является ли заданная дата текущей.
isFirstDayOfMonth(DateTime day) bool
Checks if day is in the first day of a month.
isFirstDayOfWeek(DateTime day, {int firstWeekday = DateTime.monday}) bool
Checks if day is in the first day of a week.
isLastDayOfMonth(DateTime day) bool
Checks if day is in the last day of a month.
isLastDayOfWeek(DateTime day, {int firstWeekday = DateTime.monday}) bool
Checks if day is in the last day of a week.
isLeapYear(DateTime dateTime) bool
Return whether it is leap year. 是否是闰年
isLeapYearByMilliseconds(int milliseconds) bool
Return whether it is leap year. 是否是闰年
isLeapYearByYear(int year) bool
Return whether it is leap year. 是否是闰年
isSameDay(DateTime a, DateTime b) bool
判断a和b两个时间是否是同一天
isToday(int? milliseconds, {bool isUtc = false, int? locMs}) bool
is today. 是否是当天.
isWeek(int? ms, {bool isUtc = false, int? locMs}) bool
is Week. 是否是本周.
isWeekInYear(DateTime date, int year, int firstWeekday) bool
Checks if week, that contains date is in year.
isYesterday(DateTime dateTime, DateTime locDateTime) bool
is yesterday by dateTime. 是否是昨天.
isYesterdayByMs(int ms, int locMs) bool
is yesterday by millis. 是否是昨天.
lastDayOfMonth(DateTime dateTime) DateTime
Returns DateTime that represents a beginning of the last day of the month containing date.
lastDayOfWeek(DateTime dateTime, {int firstWeekday = DateTime.monday}) DateTime
Returns start of the last day of the week for specified dateTime.
lastDayOfYear(DateTime dateTime) DateTime
Returns DateTime that represents a beginning of the last day of the year containing date.
nextDay(DateTime d) DateTime
Returns same time in the next day.
nextMonth(DateTime date) int
Returns a number of the next month.
nextYear(DateTime d) DateTime
Returns same date in the next year.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
previousDay(DateTime d) DateTime
Returns same time in the previous day.
previousYear(DateTime d) DateTime
Returns same date in the previous year.
setTime(DateTime date, int hours, int minutes, [int seconds = 0, int milliseconds = 0, int microseconds = 0]) DateTime
Creates a copy of date but with time replaced with the new values.
startOfDay(DateTime dateTime) DateTime
Returns DateTime for the beginning of the day (00:00:00).
startOfNextDay(DateTime dateTime) DateTime
Returns DateTime for the beginning of the next day (00:00:00).
startOfToday() DateTime
Returns DateTime for the beginning of today (00:00:00).
toString() String
A string representation of this object.
inherited
yearIsEqual(DateTime dateTime, DateTime locDateTime) bool
year is equal. 是否同年.
yearIsEqualByMs(int ms, int locMs) bool
year is equal. 是否同年.

Operators

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