Support

Account

Home Forums General Issues Return ACF date field in database to Gravity Forms date field using merge tags

Solving

Return ACF date field in database to Gravity Forms date field using merge tags

  • Hi, I’d like to retrieve a date field which is a custom field of user’s birth-date in gravity forms date field. I’m able to retrieve the data using {user:birth-date} merge tags, however it returned the value in a string format “yyyymmdd”, for example, “19801015”. Hence, the date picker does not recognized it as a date. How can I return it as a date in a “d-m-Y” format to the gravity forms’ date field?

    Kindly help.

  • You could try something like the below:

    <?php
    $original_date = "20211019";
     
    // Creating timestamp from given date
    $timestamp = strtotime($original_date);
     
    // Creating new date format from that timestamp
    $new_date = date("d-m-Y", $timestamp);
    echo $new_date; // Outputs: 19-10-2021
    ?>
  • Thanks for your reply. Should I enter the code in functions.php as is?

  • It depends where you need the code, if you’re using a function to handle the conversion from GF to ACF then this is where you use the code.

    How are you handling the GF to ACF part?

    It may be you need a GF function ( gform_after_submission() ) for that form, see here for examples

    But you can then convert the GF field using the above and that should update your ACF date field with the right format!

  • Hi, Did you find a solution for this? I’m also using Display Format m/d/Y for a date picker field. I’m able to get it to display in a Gravity Forms text field fine but its in Ymd format. I cannot get it to display in a Gravity Forms date field at all. Thanks.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.