Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #516703

    Hi
    My website is in ENG and FR.
    http://www.impactcrescendo.com/allo-toutlmonde?lang=fr

    I cannot figure out how to reverse the date format according to the language. I want to get the “month” and “date” reversed, so in ENG – October 10, 2015; in FR 10 octobre 2015

    I use WPML and found the following response in the forum:
    “Locate the code that outputs the date then use the php conditional logic below to output the correct date.

    global $sitepress;
    if($sitepress->get_current_language() == ‘fr’) {
    // the date format for the French version
    }
    else {
    // the date format for the English version
    }


    Can you help me find where I could try this code snippet and add it to my Child Theme functions.php.

    Thanks
    Lyse

    #517149

    Hi tremblayly!

    Thank you for using Enfold.

    Please try this in the functions.php file:

    // filter time
    add_filter('get_the_time', function($d) {
    	global $sitepress;
    	if($sitepress->get_current_language() == 'fr') {
    		$d = 'j F y';
    	}
    	
    	return $d;
    }, 10, 1);

    If you can open a new ticket in the WPML support, it will help as well.

    Best regards,
    Ismael

    #517452

    Hi Ismael,
    That code did not work, it only displays the letters “j Fy” in the date field. What’s missing in the code provided?
    I removed the code on my live site for now.
    Thanks
    Lyse

    #517459

    Hi!

    Please refer to this post – https://wpml.org/forums/topic/unable-to-translate-date-format/#post-104907

    Regards,
    Yigit

    #517541

    Hi Yigit,
    I have contacted WPML support team to help as I’ve gone through 20 different code samples and none worked.
    Thank you for you help though.
    Lyse

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘How to switch date order in French from English’ is closed to new replies.