developeraio / date-formatter
A library for php developer to formate their dates in any way without getting stuck into custom code andwasting time on the AI Tools and Core Programming to initialize custom methods
Requires
- php: ^7.4
This package is auto-updated.
Last update: 2024-10-10 19:03:31 UTC
README
Introduction
This PHP Date Formatter package provides convenient methods for formatting dates, calculating date differences, and handling timestamps in PHP applications.
Installation
You can install this package via Composer:
composer require developeraio/date-formatter
Usage
Instantiate the Date Formatter class and utilize its methods as needed.
Constructor
The constructor initializes the Date Formatter with default format and timezone settings.
public function __construct($defaultFormat = "Y-m-d H:i:s", $defaultTimezone = "UTC")
formatDateWithTimeStamp
Formats a Unix timestamp according to the specified format and timezone.
public function formatDateWithTimeStamp($timestamp, $format = null, $timezone = null)
formatDate
Formats a date string according to the specified format and timezone.
public function formatDate($dateString, $format = null, $timezone = null)
getDaysDifference
Calculates the number of days between two timestamps.
public function getDaysDifference($startTimestamp, $endTimestamp)
getHoursDifference
Calculates the number of hours between two timestamps.
public function getHoursDifference($startTimestamp, $endTimestamp)
getHoursAndMinutesDifferenceArray
Calculates the number of hours and minutes between two timestamps and returns an array.
public function getHoursAndMinutesDifferenceArray($startTimestamp, $endTimestamp)
getHoursAndMinutesDifferenceString
Calculates the number of hours and minutes between two timestamps and returns a formatted string.
public function getHoursAndMinutesDifferenceString($startTimestamp, $endTimestamp)
getYearsAndDaysDifferenceArray
Calculates the number of years and remaining days between two dates and returns an array.
public function getYearsAndDaysDifferenceArray($startDate, $endDate)
getYearsAndDaysDifferenceString
Calculates the number of years and remaining days between two dates and returns a formatted string.
public function getYearsAndDaysDifferenceString($startDate, $endDate)
Conclusion
This PHP Date Formatter package offers convenient methods for handling date and time-related operations in PHP applications.
This documentation provides clear explanations of each method available in the PHP Date Formatter package, allowing users to understand its usage and functionality easily when reading the README.md file on GitHub. Adjust the package name and namespace as necessary based on your specific implementation.