0

Is there anyway auto convert text time French become like d-m in PHP, example:

Aujourd'hui become 19-06

Hier become 18-06

17 juin become 17-06

I know use array and compare convert it to English like strtotime('yesterday') but would like to know have any other functional support auto convert it.

shilovk
  • 11,718
  • 17
  • 75
  • 74
Su Ha
  • 25
  • 7
  • 2
    Possible duplicate of [Parsing localized date strings in PHP](https://stackoverflow.com/questions/4655305/parsing-localized-date-strings-in-php) – M. Eriksson Jun 19 '18 at 05:10
  • Thanks, but sorry how to convert it when it is Hier, Aujourd'hui. Will check if else? Have anyway to do like `strtotime('Hier')`? – Su Ha Jun 19 '18 at 08:11
  • I don't think PHP will be able to translate that for you. That's named expressions for relative dates. http://php.net/manual/en/datetime.formats.relative.php. I think you need to translate those words to English yourself before you can use them. It would be pain for PHP to be able to parse every combination in every language. – M. Eriksson Jun 19 '18 at 13:24

1 Answers1

0
      $date = '17 juin';
      $french_months = array('janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre');
      $months = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
      $date = str_replace($french_months, $months, strtolower($date));

      echo $date = date('d-m-Y', strtotime($date));
      echo "</br>";
      echo $date = date('d-m', strtotime($date))
F5 Buddy
  • 474
  • 4
  • 4