This is an API to calculate the days between time period.
To run this project successfully, you need
- PHP 8.3
- open extension=fileinfo in php.ini
- Composer
cd date-time-apicomposer install --no-scriptsphp artisan serve
Download the date-time-api collection from postman-collection folder and import to postman to do the testing.
The below table shows the parameters using in API:
| Component | Type | Format | Description |
|---|---|---|---|
| first_date | Compulsory | yyyy-mm-dd HH:mm:ss | The first date used to calculate the time difference, return 422 error if the first date is missed |
| second_date | Compulsory | yyyy-mm-dd HH:mm:ss | The second date used to calculate the time difference, return 422 error if the second date is missed |
| first_date_timezone | Optional | Text | Default value: Australia/Adelaide, using to setup the first date timezone |
| second_date_timezone | Optional | Text | Default value: Australia/Adelaide, using to setup the second date timezone |
| type | Optional | Text | Default value: Days. Options: Days, Weekdays, Weeks. |
| convert | Optional | Text | Default value: Days. Options: Days, Hours, Minites, Seconds, Years |
The below table shows the response from API:
| Component | Type | Format | Description |
|---|---|---|---|
| status | Compulsory | Boolean | False: invalid Date, True: successful request |
| code | Compulsory | Number | The second date used to calculate the time difference |
| First Date | Optional | Date | Fisrt date from the request |
| First Date Timezone | Optional | Text | Fisrt date timezone from the request |
| Second Date | Optional | Date | Second date from the request |
| Second Date Timezone | Optional | Text | Second date timezone from the request |
| Request Type | Optional | Text | Request Type from the request |
| Result Convert To | Optional | Text | Result will convert to options |
| Time difference | Optional | Text | Final Result |
cd date-time-apiphp artisan test
- using xml as request body if there are more request parameters.
- add authentication function, such as using hash_hmac function and preshared key