1

Here's my code:

$date_depo = date('d-m-Y', strtotime($date_depot));

So in my excel table I have => 2 nov 16 00:00:00
and this code changes it to => 02-11-2016

But if I have 10 mai 13 00:00:00 it changes it to 01-01-1970 it means that the value is 0 or something like that, how can I change it to => 10-05-2013

Edit:

setlocale (LC_TIME, 'fr_FR.utf8','fra'); 
$date_depo = strftime('%Y-%m-%d', $date_depot);   

Doesn't work.

Cœur
  • 37,241
  • 25
  • 195
  • 267
elianero
  • 27
  • 5
  • `mai` should be `may` to be properly parsed by php – u_mulder Nov 17 '16 at 15:16
  • @u_mulder Indeed, but they may not have complete control over that. Therefore, they'd need something else to recognize the language set. Say like set locale maybe (in French). – Funk Forty Niner Nov 17 '16 at 15:17
  • i see, is there a way to change that or do i have to write a code that changes all of the months to english? – elianero Nov 17 '16 at 15:18
  • @elianero You can try set locale http://php.net/manual/en/function.setlocale.php --- http://php.net/manual/en/function.strftime.php --- http://stackoverflow.com/questions/7309960/change-month-name-to-french --- http://stackoverflow.com/questions/21430767/php-print-month-in-french - and the last one which happens to contain an answer for it that I gave; didn't even know that lol – Funk Forty Niner Nov 17 '16 at 15:19
  • yes, thanks a lot! I'm just new to PHP – elianero Nov 17 '16 at 15:23
  • @Fred -ii- it didn't work :/ – elianero Nov 17 '16 at 16:02

1 Answers1

0
$trans = array('janv' => 'January ','févr' => 'February','mars' => 'March ','avr' => 'April','mai' => 'May','juin' => 'June','juil' => 'July','août' => 'August','sept' => 'September','oct' => 'October','nov' => 'November','déc' => 'December');
                $resulat= strtr($date_depot,$trans);
                $date_depot_t = date('d-m-Y', strtotime($resulat));    

Had to replace every month, but it works!

elianero
  • 27
  • 5