PHP code example of mokhosh / jarbon

1. Go to this page and download the library: Download mokhosh/jarbon library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mokhosh / jarbon example snippets


$user->created_at->jormat($format) // see links below to know more about date formats

class User extends Model
{
    use JarbonTrait;
}

$user->created_at->toJString(); // 12:36:20 چهارشنبه 27 شهریور 1398
$user->created_at->toJDateString(); // 1398-06-27
$user->created_at->toJFormattedDateString(); // 27 شهریور 1398
$user->created_at->toJTimeString(); // 12:36:20 i know! but this will render in persian digits if you set the config
$user->created_at->toJDateTimeString(); // 1398-06-27 12:36:20 same as implicit toString in blade but you need to call this explicitly elsewhere
$user->created_at->toJDayDateTimeString(); // چهارشنبه 27 شهریور 1398 12:36 ب.ظ

// config/jarbon.php

return [

    'default_format' => 'Y-m-d H:i:s', // to render $carbon->jormat() differently
    'convert_numbers' => false, // set to true to get dates like چهارشنبه ۲۷ شهریور ۱۳۹۸ ۱۲:۳۶ ب.ظ

];

php artisan vendor:publish --tag=config
or in case I add more publishable stuff:
php artisan vendor:publish --provider="Mokhosh\Jarbon\JarbonServiceProvider"