PHP code example of shafayat / date-formatter

1. Go to this page and download the library: Download shafayat/date-formatter 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/ */

    

shafayat / date-formatter example snippets


return [
    'default_format' => 'Y-m-d',
    'styles' => [
        'short' => 'm/d/Y',
        'long' => 'F d, Y',
        'custom' => 'd-m-Y H:i:s',
    ],
];

use Shafayat\DateFormatter\DateFormatter;

// Format a string date
echo DateFormatter::format('2024-01-01', 'short'); // Output: 01/01/2024

// Format a DateTime instance
$date = new \DateTime('2024-01-01');
echo DateFormatter::format($date, 'long'); // Output: January 01, 2024

echo DateFormatter::format('2024-01-01'); // Output: 2024-01-01
bash
php artisan vendor:publish --tag=config