display month in french in wordpress/php?

Question

I am working on a php code as shown below:

<?php <time datetime="<?php  echo esc_attr(date_format($ts, 'H:i d-m-Y'))  ?>"
data-timezone="<?php  echo esc_attr($tz_param)  ?>"><?php echo esc_html(date_format($ts, 'F j  H:i')) ?></time> ?> // Line A 

Line A returns the following date (which is in English):

July 10 21:30

print_r($ts) prints:

DateTime Object
(
    [date] => 2019-07-10 21:30:00.000000
    [timezone_type] => 3
    [timezone] => America/New_York
)
July 10  21:30

Problem Statement:

I am wondering what changes I should make in the php code above at Line A above so that when the page is in french, it should return the DATE IN FRENCH.

This is what I have tried but it is still returning the date in Engllish.

<?php if(ICL_LANGUAGE_CODE=='fr'){   /* If the page is in french */
setlocale(LC_TIME, 'fr_FR');
?>
<time datetime="<?php echo esc_attr(date_format($ts, 'H:i d-m-Y')) ?>"
   data-timezone="<?php echo esc_attr($tz_param) ?>"><?php echo strftime(esc_html(date_format($ts, 'F j  H:i'))) ?></time> // Line B
<?php } ?>

Line B still returns english even after using strftime.

0
, , , user5447339 2 years 2019-07-17T11:00:39-05:00 0 Answers 86 views 0

Leave an answer

Browse
Browse