Last active
March 25, 2016 10:13
-
-
Save ismnoiet/a93a62bf5ab9bfb7fdef to your computer and use it in GitHub Desktop.
Convert date to french format in PHP without using locals
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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