0

What is the correct way to write this code so that the output date is properly formatted for French?

<?php $questiondate = date('F d, Y', strtotime('-1 week')); ?>

This code works correctly for English, but I have searched on here for how to do this in French, and none of the threads I found work when I put them in my code.

I have tried the following:

<?php setlocale (LC_TIME, 'fr_FR.utf8','fra'); ?>
<?php $questiondate = strftime('%d %B %Y', strtotime('-1 week')); ?>

But the month is being written in English instead of French.

Thanks in advance.

I have looked at the other threads, but those answers didn't work for what I am trying to do here, which is output a date that is 1 week in the past in French.

  • have you looked at setlocale() and strftime() functions ? – Clint Aug 02 '18 at 20:12
  • You mean like `July 4th = July 14th`? – ficuscr Aug 02 '18 at 20:13
  • "none of the threads I found work when I put them in my code" Show your attempt(s) and describe the result(s) including any error message(s). Also, please provide your desired result. What exactly does "properly formatted for French" mean to you? – Patrick Q Aug 02 '18 at 20:16
  • I have looked at the other threads, but those answers didn't work for what I am trying to do here, which is output a date that is 1 week in the past in French. – Shayne Sherman Aug 02 '18 at 20:34
  • Please read my comment above. We can't really help you further without you providing additional information. – Patrick Q Aug 02 '18 at 20:44
  • Patrick, thanks for taking your time I really appreciate it. I have tried the following: setlocale(LC_TIME, "fr_FR"); but the date is still being written as: 26 July 2018 When I would like it written as: 26 juillet 2018 – Shayne Sherman Aug 02 '18 at 20:53
  • This has already been marked as a duplicate of a different question, but I actually think that it should be a duplicate of https://stackoverflow.com/questions/10909911/php-setlocale-has-no-effect @JayBlanchard could you change that or maybe add it as an additional dupe? – Patrick Q Aug 02 '18 at 21:14

0 Answers0