One way to do it would be to use PHPs substr
function as follows:
$translate_fr = substr(strftime("%h", strtotime($data_event)), 0, 3);
Edit: In case not all months should be abbreviated to three characters, it would be possible to use an associative array as a map:
$abr_map = array(
'JANV' => 'Jan',
'FÉVR' => 'Fév',
'MARS' => 'Mar',
'AVRI' => 'Avr',
'MAI' => 'Mai',
'JUIN' => 'Juin',
'JUIL' => 'Juil',
'AOUT' => 'Aout',
'SEPT' => 'Sept',
'OCTO' => 'Oct',
'NOVE' => 'Nov',
'DÉCE' => 'Déc'
);
Alternatively using intval
and strftime
s %m
formatter to provide an integer "key" for an indexed array:
$id = intval(strftime("%m", strtotime($data_event))) - 1;
$abr_map = array(
'Jan',
'Fév',
'Mar',
'Avr',
'Mai',
'Juin',
'Juil',
'Aout',
'Sept',
'Oct',
'Nov',
'Déc'
);
To use the map within the function, you would then use
$translate_fr = htmlentities(utf8_decode($abr_map[$id]));
or alternatively using htmlentities
built in encoder:
$translate_fr = htmlentities($abr_map[$id], ENT_COMPAT, 'UTF-8');