0

I have a php_view field in a view, it basically pulls a date field on a specific node, and then use the php function setISODate to get the 'monday' date of the week.

The thing is, i'm on a french language site and the date that the function return is in english, not that I don't like english hehe but the month just doesn't fit very well in the display on that view

Here's the code.

// Retrieve the date field of that node.
$node = node_load($data->nid);
$date_field = $node->field_date;
$date = $date_field['und'][0]['value'];

// Put the year in $annee and the week number in $semaine.
$annee = date("Y", strtotime($date));
$semaine= date("W", strtotime($date));

// Get the monday date of that week
$lundi = new DateTime();
$lundi->setISODate($annee , $semaine);
print "Semaine du " . $lundi->format('j F Y');;

?>

I've tried to use the following code, but it doesn't do anything.

setlocale (LC_TIME, 'fr_FR.utf8','fra'); 
print (strftime("%j %F %Y", $lundi)); 

1 Answer 1

1

This is working :

setlocale(LC_TIME, 'French_France.utf-8', 'fr.UTF8', 'fr_FR.UTF-8', 'fr.UTF-8');
//setlocale(LC_ALL, '') ;// if you try on local windows server

$annee = date("Y", strtotime($date));
$semaine= date("W", strtotime($date));

// Get the monday date of that week
$lundi = new DateTime();
$lundi->setISODate($annee , $semaine);

print "Semaine du " . strftime("%A %d %B %Y",strtotime($lundi->format('j F Y')));
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.