• Resolved locker17

    (@locker17)


    Unfortunately the date saving problem which you marked as solved is not solved yet.
    I was asking to show the date from the date picker as d/m/Y or d-m-Y but save it as Y-m-d 00:00:00 like mysql datetime or date format.
    You wrote this:

    add_filter( 'user_registration_validate_date', 'ur_format_date_field', 10, 4 );
     
    function ur_format_date_field($single_form_field, $data, $filter_hook, $form_id) {
     
       // Change format of the date
     
    }

    I need more help with that. How to change it, do I have to return any value??? Does $data holds the date as d/m/Y?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Sandip Pokhrel

    (@sandippokharel)

    Hi @locker17

    Here is the required code.

    add_filter( 'user_registration_validate_date', 'ur_format_date_field', 11, 4 );
     
    function ur_format_date_field($single_form_field, $data, $filter_hook, $form_id) {
     
       if ( isset( $data->value ) ) {
        $timestamp = DateTime::createFromFormat('d/m/Y', $data->value);
     
        $formattedDate = $timestamp->format('Y/m/d 00:00:00');
        $data->value   = $formattedDate;
       }
     
       return $data;
    }

    Note: This works only during the registration process.

    Regards!

    Thread Starter locker17

    (@locker17)

    tested, works. Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Date from date picker cannot mapped correctly’ is closed to new replies.