Jump to content

PHP convert English date to French date


shayne54

Recommended Posts

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 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.

Thanks in advance.

Link to comment
Share on other sites

Have you read the manual on the date() function?  And read up on what those formatting characters are for?  So simply re-arrange the format chars to get what you want.

Right now you are getting January 01, 1992 out of your date call.  What do the French use for a date?

Link to comment
Share on other sites

Thanks for your reply.

The date in French should be: day name of month year example: 06 juin 2018

I have tried this code:

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

But that outputs the month in English ( 26 July 2018 )

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.