Date Manager
PHP Class Date Manager
Version 1.0.0
PHP class for date management, for example converting solar date to gregorian date and vice versa.
Contents
Methods
Name | Arguments | Options | Description |
---|---|---|---|
gregorianToSolar | Date | Sign, Format | Convert Gregorian Date To Solar Date |
solarToGregorian | Date | Sign, Format | Convert Solar Date To Gregorian Date |
solarDate | - | Format | Return Solar Date |
Options
Name | Description |
---|---|
Sign | The Mark between year, month and date For example, you can use the '-' or '/' sign. default is '-' |
Format | Format the return date ymd: return year-month-day dmy: return day-month-year mdy: return month-day-year ym: return year-month md: return month-day y: return year m: return month d: return day |
Usage
require 'DateManager.php';
$date = new DateManager();
Example
Without options
Convert gregorian date to solar date
//without options
echo $date->gregorianToSolar('2021-07-22');
1400-04-31
Convert solar date to gregorian date
//without options
echo $date->solarToGregorian('1400-04-31');
2021-07-22
Get solar date
//without options
echo $date->solarDate();
1400-04-31
With options
Sign '-' and Year-month-day format
//Return with '-' sign and Year-Month-Day format
echo $date->gregorianToSolar('2021-07-22',['sign'=>'-','format'=>'ymd']);
1400-04-31
Sign '/' and Day-Month-Year format
//Return with '/' sign and Day-Month-Year format
echo $date->gregorianToSolar('2021-07-22',['sign'=>'/','format'=>'dmy']);
31/04/1400
Sign '/' and Month-Day-Year format
//Return with '/' sign and Month-Day-Year format
echo $date->gregorianToSolar('2021-07-22',['sign'=>'/','format'=>'mdy']);
04/31/1400
Sign '/' and Year-Month format
//Return with '/' sign and Year-Month format
echo $date->gregorianToSolar('2021-07-22',['sign'=>'/','format'=>'ym']);
1400/04
Sign '/' and Month-Day format
//Return with '/' sign and Month-Day format
echo $date->gregorianToSolar('2021-07-22',['sign'=>'/','format'=>'md']);
04/31
Sign '/' and Year format
//Return with '/' sign and Year format
echo $date->gregorianToSolar('2021-07-22',['sign'=>'/','format'=>'y']);
1400