• Resolved root09

    (@root09)


    how to have date in european format ?
    like this … 24/01/2019 Day Month Year

    now, is … february 2, 1912 (exemple)

    thanks πŸ™‚

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hey @root09!

    HappyForms doesn’t include a way to do this yet, we’re sorry! We’re definitely taking note, it would be a really nice improvement.

    You can customize the way dates look in your emails with a bit of PHP though. Let us know in case you’re interested!

    Thread Starter root09

    (@root09)

    Hey @thethemefoundry

    do you know… πŸ˜‰
    interested ! of course !

    Nice, @root09!

    The filter you’re looking for is happyforms_stringify_part_value. Here’s a starter:

    function happyforms_custom_date_string( $value, $part ) {
        if ( 'date' === $part['type'] ) {
            // Process your date value here
        }
    
        return $value;
    }
    
    add_filter( 'happyforms_stringify_part_value', array( $this, 'stringify_value' ), 50, 3 );

    When the value reaches your hook it will be already converted to a string. Hooking earlier (for example, setting the priority to 5) lets you access the raw underlying array of single date components. That gives you more power, but also more responsibility: date values come through in different formats depending on your settings, and you’ll have to handle things correctly to avoid fatal errors.

    All in all, I think working with the string value is easier.

    I hope that helps! Let us know how you go! πŸ™‚

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘how to have date in european format ?’ is closed to new replies.