approached / laravel-date-international by approached

Date manipulator for laravel
31,334
11
3
Package Data
Maintainer Username: approached
Maintainer Contact: alexejkloos@gmail.com (Alexej Kloos)
Package Create Date: 2015-07-10
Package Last Update: 2022-05-08
Home Page:
Language: PHP
License: MIT
Last Refreshed: 2024-12-16 15:04:12
Package Statistics
Total Downloads: 31,334
Monthly Downloads: 187
Daily Downloads: 2
Total Stars: 11
Total Watchers: 3
Total Forks: 5
Total Open Issues: 0

Laravel date international

License Latest Stable Version Total Downloads

With this package you can get easy formated date string in your language.

Demo

German:

Date:
20.08.15
20.08.2015
20. August 2015
Donnerstag, 20. August 2015

Time:
13:21
13:21:54 (with seconds)

Full:
20.08.15 13:21
20.08.2015 13:21
20. August 2015 13:21
Donnerstag, 20. August 2015 13:21

Italy:

Date:
20/08/15
20/ago/2015
20 agosto 2015
giovedì 20 agosto 2015

Time:
13:26
13:26:36 (with seconds)

Full:
20/08/15 13:26
20/ago/2015 13:26
20 agosto 2015 13:26
giovedì 20 agosto 2015 13:26:36 (with seconds)

English:

Date:
8/20/15
Aug 20, 2015
August 20, 2015
Thursday, August 20, 2015

Time:
1:25 PM
1:25:28 PM (with seconds)

Full:
8/20/15, 1:25 PM
Aug 20, 2015, 1:25 PM
August 20, 2015 at 1:25 PM
Thursday, August 20, 2015 at 1:25:28 PM (with seconds)

Spanish:

Date:
20/8/15
20/8/2015
20 de agosto de 2015
jueves, 20 de agosto de 2015

Time:
13:27
13:27:42 (with seconds)

Full:
20/8/15 13:27
20/8/2015 13:27
20 de agosto de 2015, 13:27
jueves, 20 de agosto de 2015, 13:27:42 (with seconds)

And many more...

Installation

Languages

You can look all available language packages with:

aptitude search language-pack-

Install some languages:

sudo apt-get install language-pack-de language-pack-en language-pack-es language-pack-it
sudo locale-gen

Check your available languages:

locale -a

Make sure that you have languages in format like this: de_DE

Php extension

Install php international support:

sudo apt-get install php-intl 

Check that this extension is included:

php -m | grep intl

Laravel

Laravel require this package with composer:

composer require approached/laravel-date-international

After updating composer, add the ServiceProvider to the providers array in config/app.php:

Approached\LaravelDateInternational\ServiceProvider::class,

and

'Dateintl'=> Approached\LaravelDateInternational\DateIntlFacade::class,

Usage

Blade:

    Date:<br>
    {{ dateintl_date('short', $date) }}<br>
    {{ dateintl_date('medium', $date) }}<br>
    {{ dateintl_date('long', $date) }}<br>
    {{ dateintl_date('full', $date) }}<br><br>

    Time:<br>
    {{ dateintl_time($date) }}<br>
    {{ dateintl_time($date, true) }} (with seconds)<br><br>

    Full:<br>
    {{ dateintl_full('short', $date) }}<br>
    {{ dateintl_full('medium', $date) }}<br>
    {{ dateintl_full('long', $date) }}<br>
    {{ dateintl_full('full', $date, true) }}  (with seconds)<br>

PHP:

$str = Dateintl::full('short', $date);

Calendar:

With the last parameter you can control which calendar you want to use:

$str = Dateintl::full('short', $date, false, 'japanese');

Could be these values :

  • persian
  • japanese
  • buddhist
  • chinese
  • indian
  • islamic
  • hebrew
  • coptic
  • ethiopic

License

MIT