Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/novaday-co/laravel-persian-datetime-helper
Laravel Persian DateTime Helper
https://github.com/novaday-co/laravel-persian-datetime-helper
helper-functions jalali-datetime laravel persian-datetime php
Last synced: about 13 hours ago
JSON representation
Laravel Persian DateTime Helper
- Host: GitHub
- URL: https://github.com/novaday-co/laravel-persian-datetime-helper
- Owner: novaday-co
- License: mit
- Created: 2021-07-03T09:22:49.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-09-20T08:01:08.000Z (about 3 years ago)
- Last Synced: 2024-07-29T16:32:29.154Z (4 months ago)
- Topics: helper-functions, jalali-datetime, laravel, persian-datetime, php
- Language: PHP
- Homepage:
- Size: 36.1 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Laravel Persian DateTime Helper
## Install
### Composer
Installing with composer is recommended and it simply works :
```composer
composer require novaday-co/laravel-persian-datetime-helper
```### Download
You can download latest version from the Github: Download## Quick start
To use in your project, just import `DateTimeHelper` class :```php
$instance = DateTimeHelper::parse('1400-04-13 15:16:10') : Jalalian
$instance = DateTimeHelper::parse('1400/04/13 15:16:10') : Jalalian
$instance = DateTimeHelper::parse('1400_04_13 15:16:10') : JalalianDateTimeHelper::parse('1400-04-13 15:16:10')->format('Y-m-d') : string
// 1400-04-13DateTimeHelper::parse('1400/04/13 15:16:10')->format('Y/m/d') : string
// 1400/04/13
```
---```php
// Accept H:i FormatDateTimeHelper::parse('1400/04/13 15:16')->format('Y-m-d H:i:s') : string ('Y-m-d H:i:s')
// 1400-04-13 15:16:00
```
---```php
// Clone$jalaliDateTime = DateTimeHelper::parse('1400-04-13 15:16:10');
$cloneJalaliDateTime = DateTimeHelper::copy($jalaliDateTime)->format('Y-m-d H:i:s');
// 1400-04-13 15:16:10
// $jalaliDateTime == $cloneJalaliDateTime
// $jalaliDateTime !== $cloneJalaliDateTime
```
---```php
//ignore multiple space from input$instance = DateTimeHelper::parse('1400-04-13 15:16:10')->format('Y-m-d H:i:s') : string
// 1400-04-13 15:16:10
```
---```php
DateTimeHelper::jalaliToGregorian('1400-04-13 15:16:10') : string ('Y-m-d H:i:s')
// 2021-07-04 15:16:10DateTimeHelper::jalaliToGregorian('1400-04-13') : string ('Y-m-d H:i:s')
// 2021-07-04 00:00:00
```
---```php
DateTimeHelper::jalaliDiffInMonths('1400-02-23 10:27:52', '1400-04-23 15:16:10') : int
// 2DateTimeHelper::jalaliDiffInMonths('1400-02-23', '1400-04-23') : int
// 2
```
---```php
DateTimeHelper::jalaliDiffInDays('1400-02-13 15:16:10', '1400-02-23 10:27:52') : int
// 9DateTimeHelper::jalaliDiffInDays('1400-02-13', '1400-02-23') : int
// 10
```
---```php
DateTimeHelper::jalaliDiffInHours('1400-04-23 15:16:10', '1400-04-23 22:27:52') : int
// 7DateTimeHelper::jalaliDiffInHours('15:16:10', '22:27:52') : int
// 7
```
---
```php
DateTimeHelper::jalaliDiffInMinutes('1400-04-23 15:16:10', '1400-04-23 22:27:52') : int
// 431DateTimeHelper::jalaliDiffInMinutes('15:16:10', '22:27:52') : int
// 431
```
---```php
DateTimeHelper::clearTime('1400-04-23 15:16:10') : string ('Y-m-d H:i:s')
// 1400-04-23 00:00:00
```
---
```php
DateTimeHelper::getMinutes('1400-04-23 15:16:10') : int
// 916 = 15*60 + 16
```
---
```php
DateTimeHelper::firstDayOfMonth('1400-04-23 15:16:10') : string ('Y-m-d H:i:s')
// 1400-04-01 00:00:00DateTimeHelper::firstDayOfMonth('1400-04-23') : string ('Y-m-d H:i:s')
// 1400-04-01 00:00:00
```
---
```php
DateTimeHelper::lastDayOfMonth('1400-04-23 15:16:10') : string ('Y-m-d H:i:s')
// 1400-04-31 00:00:00DateTimeHelper::lastDayOfMonth('1400-08-23') : string ('Y-m-d H:i:s')
// 1400-08-30 00:00:00
```
---
```php
DateTimeHelper::firstDayOfYear() : string ('Y-m-d H:i:s')
// 1400-01-01 00:00:00
```
---
```php
DateTimeHelper::lastDayOfYear() : string ('Y-m-d H:i:s')
// 1400-12-29 23:59:59
```## License
### MIT