hekmatinasser/verta
Document
The Verta is package for change solar calendar and gregorian together and provide helper function to use date and time.
Verta extend class PHP Datetime and Jalali, compatible with Carbon Package.
Quick view
- Installation
- Usage
- Getters
- Setters
- Formatting
- Modification
- Boundaries
- Compression
- Validation
- Localization
- Validation Request
- Licence
- Contributors
Installation
composer require hekmatinasser/verta| Laravel Version | Package Version |
|---|---|
| 8.0 | 8.x |
| 9.0 | 8.x |
Usage
use verta datetime jalali
echo verta(); //1401-05-24 00:00:00Gregorian to Jalali
change gregorian to jalali and reverse
echo verta('2022-08-15'); //1401-05-24 00:00:00jalali to Gregorian
change jalali to gregorian and reverse
echo Verta::parse('1401-05-24 14:12:32')->datetime(); //2022-08-15 00:00:00Carbon to Jalali
change carbon to jalali and reverse
echo now()->toJalali(); //1401-05-24 00:00:00Jalali to Carbon
change jalali to gregorian and reverse
echo verta()->toCarbon(); //2022-08-15 00:00:00Getters
access part of jalali datetime
$v = verta(); // 1396-03-14 14:18:23
echo $v->year; // 1396Setters
set part of jalali datetime
$v = verta(); // 1396-03-14 14:18:23
echo $v->year = 1395;Fluent Setters
set multiple part of jalali datetime
$v = verta(); // 1396-03-14 14:18:23
echo $v->setTimeString('12:25:45');Formatting
show datetime variant datetime
echo verta()->format('Y.m.d'); // 1401.05.24
echo verta()->formatWord('l dS F'); // دوشنبه بیست و چهارم مردادCommon Formats
show common datetime variant datetime
echo verta()->formatJalaliDatetime(); // output 1395/10/07 14:12:25Difference for Humans
show difference format readable humans
echo verta('-13 month')->formatDifference(); // 1 سال قبلModification
manipulate jalali datetime
echo verta()->addWeeks(3);
...Boundaries
get boundary jalali datetime
echo verta()->startWeek(3); Compression
get compression jalali datetime
echo verta('+2 day')->gte('2022-08-15');Difference
calculate difference two jalali datetime
echo verta('+13 day')->diffMonths('2022-08-15'); Validation
check datetime check is valid
echo Verta::isLeapYear(1394); // falseLocalization
set language for formatting datetime
Verta::setLocale('ar');Validation Request
validation input form
'birthday' => ['required', 'jdate_before_equal']Licence
This package has been created by Nasser Hekmati under the license of MIT.
Contributors
Thanks to people who contributed for grow verta.
