Skip to content

Instantly share code, notes, and snippets.

@ismnoiet
Last active March 25, 2016 10:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ismnoiet/a93a62bf5ab9bfb7fdef to your computer and use it in GitHub Desktop.
Save ismnoiet/a93a62bf5ab9bfb7fdef to your computer and use it in GitHub Desktop.
Convert date to french format in PHP without using locals
<?php
function to_french_format($date){
$date = date("l d/m/Y h:i", strtotime($date));
$date_components = split(' ',$date);
$french_days = array(
'Saturday'=>'Samedi',
'Sundy'=>'Dimanche',
'Monday'=>'Lundi',
'Tuesday'=>'Mardi',
'Wednesday'=>'Mercredi',
'Thursday'=>'Jeudi',
'Thursday'=>'Jeudi'
);
$key = $date_components[0];
if(array_key_exists($key, $french_days)){
$date = str_replace($key,$french_days[$key],$date);
}
return $date;
}
$originalDate = '2016-03-01 10:20:30';
echo to_french_format($originalDate);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment