The implementation of JavaScript Library date-fns
by using PHP
Copy from date-fns
We can simply add the package into our project by using Composer
to run the command below:
composer require a2htray/cp-date-fns:dev-master
Method | Description |
---|---|
Utils::addYears | Return the date added serveral years |
Utils::addQuarters | Return the date add several quarters |
Utils::addMonths | Return the date add several months |
Utils::addDays | Return the date add several days |
Utils::addHours | Return the date add several hours |
Utils::addMinutes | Return the date add several minutes |
Utils::addSeconds | Return the date add serveral seconds |
Utils::addMilliseconds | Return the date add serveral milliseconds |
Utils::closeIndexTo | Return an index of the closest date from the array comparing to the given date |
Utils::compareAsc | Compare two dates return 1、-1 or 0 |
Utils::compareDesc | Compare two dates return 1、-1 or 0 |
Utils::differenceInDays | Get the number of full days between two given dates |
Utils::differenceInHours | Get the number of hours between two given dates |
Utils::differenceInCalendarDays | Get the number of calendar days between two given dates |
Utils::differenceInCalendarMonths | Get the number of calendar months between two given dates |
Utils::differenceInCalendarQuarters | Get the number of calendar quarters between two given dates |
Utils::differenceInCalendarYears | Get the number of calendar years between two given dates |
Utils::getQuarter | Return the order of the given date in current year |
Utils::getMilliseconds | Return the milliseconds of the given date |
Utils::startOfDay | Get the start date of the given date |
Utils::subDays | Subtract serveral days form the given date, then return the date after subtraction |
Utils::subHours | Subtract serveral hours form the given date, then return the date after subtraction |
Utils::endOfDay | Get the end date of the given date |
Utils::endOfDecade | Get the date which is the end date of current decade of the given date |
Utils::endOfHour | Get the date which is the end date of current hour of the given date |
Utils::endOfMonth | Get the date which is the end date of current month of the given date |
Utils::endOfMinute | Get the date which is the end date of current minute of the given date |
Utils::endOfSecond | Get the date which is the end date of current second of the given date |
Utils::endOfWeek | Get the date which is the end date of current week of the given date |
Utils::endOfYear | Get the date which is the end date of current year of the given date |
Utils::endOfQuarter | Get the date which is the end date of current quarter of the given date |
Utils::isMonday | Whether is Monday |
Utils::isTuesday | Whether is Tuesday |
Utils::isWednesday | Whether is Wednesday |
Utils::isThursday | Whether is Thursday |
Utils::isFriday | Whether is Friday |
Utils::isSaturday | Whether is Saturday |
Utils::isSunday | Whether is Sunday |
Utils::isSameDay | Whether is same between two given dates |
Utils::isFirstDayOfMonth | Whether is the first day of the month |
Utils::isLastDayOfMonth | Whether is the last day of the month |