0

Blade.php

<tr>
   <td class="lesDates"> 
       <?php            
          $date = strtotime($formation['annee_obtention']);
          echo date('D / M / Y ', $date);  
       ?>    
   </td>
</tr>

I would like to show it in French long format.

Arun J
  • 687
  • 4
  • 14
  • 27
DZDZD
  • 1
  • What is `french long format`? Can you provide an example please? – user3783243 Feb 03 '20 at 01:37
  • February 2, 2020 ==> french format : 2 février 2020 – DZDZD Feb 03 '20 at 01:42
  • Okay, so you want the `locale` to be set to french then the `date` function will just need the appropriate values – user3783243 Feb 03 '20 at 01:44
  • 1
    Does this answer your question? [change month name to french](https://stackoverflow.com/questions/7309960/change-month-name-to-french) – user3783243 Feb 03 '20 at 01:44
  • Does this answer your question? [Convert a date format in PHP](https://stackoverflow.com/questions/2487921/convert-a-date-format-in-php) – Calos Feb 03 '20 at 01:55
  • Does this answer your question? [php get locale specific date format](https://stackoverflow.com/questions/22737272/php-get-locale-specific-date-format) – Triby Feb 03 '20 at 03:18

2 Answers2

0

in laravel you can use Carbon to managing date or time in you application. check out this https://carbon.nesbot.com/docs/

in carbon,you can format the date using simple code. example in Carbon docs

// Let say Martin from Paris and John from Chicago play chess
$martinDateFactory = new Factory([
'locale' => 'fr_FR',
'timezone' => 'Europe/Paris',
]);
$johnDateFactory = new Factory([
    'locale' => 'en_US',
    'timezone' => 'America/Chicago',
]);
// Each one will see date in his own language and timezone

// When Martin moves, we display things in French, but we notify John in English:
$gameStart = Carbon::parse('2018-06-15 12:34:00', 'UTC');
$move = Carbon::now('UTC');
$toDisplay = $martinDateFactory->make($gameStart)->isoFormat('lll')."\n".
$martinDateFactory->make($move)->calendar()."\n";
$notificationForJohn = $johnDateFactory->make($gameStart)->isoFormat('lll')."\n".
$johnDateFactory->make($move)->calendar()."\n";
echo $toDisplay;
/*
15 juin 2018 12:34
Aujourd’hui à 12:40
*/

echo $notificationForJohn;
/*
Jun 15, 2018 12:34 PM
Today at 12:40 PM
*/
M. Fahmi Ulul Azmi
  • 90
  • 1
  • 3
  • 15
0

Use this Repository : https://github.com/jenssegers/laravel-date

To install this library you can follow these instructions: https://github.com/jenssegers/laravel-date#installation

Using a library as Laravel-Date you will just need to set the language of the app in the Laravel app config file and use its functions to format the date as you want.

Set the language in /app/config/app.php

'locale' => 'fr',

Examples:

use Jenssegers\Date\Date;

Date::setLocale('nl'); //Change this to your preferred locale

echo Date::now()->format('l j F Y H:i:s'); // zondag 28 april 2013 21:58:16

echo Date::parse('-1 day')->diffForHumans(); // 1 dag gelede

Hindi Example:

 Date::setLocale('hi');

 echo Date::now()->format('l j F Y H:i:s'); 

French Example:

 Date::setLocale('fr');

 echo Date::now()->format('l j F Y H:i:s'); 
Shamsheer
  • 734
  • 4
  • 8