Skip to content

A library for PHP developer to format their dates in any way without getting stuck into custom code and wasting time on the AI Tools and Core Programming to initialize custom methods

License

Notifications You must be signed in to change notification settings

salamalsam/php-date-formatter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP Date Formatter Package Documentation

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.

About

A library for PHP developer to format their dates in any way without getting stuck into custom code and wasting time on the AI Tools and Core Programming to initialize custom methods

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages