Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parse french date in php

Tags:

date

php

I have string:

"Lundi, 08 Juillet 2013 09:09"

How can I parse this type string?

I try:

    $date = '08 Juillet 2013 09:09';
    $date = new \DateTime($date);

But it throw exception

like image 620
korvinko Avatar asked Jul 09 '13 06:07

korvinko


1 Answers

The intl extension can be used for this:

// create formatter
$fmt = new IntlDateFormatter(
    "fr-FR", 
    IntlDateFormatter::FULL, 
    IntlDateFormatter::FULL, 
    'Etc/UTC', 
    IntlDateFormatter::GREGORIAN, 
    'EEEE, dd MMMM y hh:mm'
);

// parse
$ts = $fmt->parse('Lundi, 08 Juillet 2013 09:09');
echo $ts; // 1373274540
like image 93
Ja͢ck Avatar answered Oct 14 '22 10:10

Ja͢ck