Store month in local format

Support Meta Box AIO Store month in local formatResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #40499
    info@ivanit.nl[email protected]
    Participant

    I added a custom field with a date picker and date format "d F o".

    The month I want it to be in Dutch but it stores in English.

    Example: 10 January 2023 is saved.
    Wanted: 10 Januari 2023 (month is spelled different).

    How can this be achieved?

    Kind regards,

    Ivan.

    #40500
    PeterPeter
    Moderator

    Hello,

    You can use the filter hook rwmb_{$field_id}_value to format the date value before saving it to the database. For example:

    add_filter( 'rwmb_date_03tqmu7k17qs_value', function( $new, $field, $old, $object_id ) {
        $timestamp = strtotime( $new );
        $new = wp_date( 'd F o', $timestamp );
        return $new;
    }, 99, 4 );
    

    replace date_03tqmu7k17qs with your field date ID. Please read more on the documentation
    https://docs.metabox.io/filters/rwmb-field-type-value/
    https://developer.wordpress.org/reference/functions/wp_date/

    #40510
    info@ivanit.nl[email protected]
    Participant

    This was too easy and I should have found this in the forum.

    It works and thank you for your help!

    Kind regards,

    Ivan.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.