Custom Fields
Re-Envisioned
Support General Chinese character in date picker

  • Creator
    Topic
  • #28940
    chillifish
    Participant

    There is a Chinese character appearing in my datepicker. I'm not sure why this is… screenshot here.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Author
    Replies
  • #28946
    Long Nguyen
    Moderator

    Hi,

    It might relate to the language or a plugin activated on your site. Please go to Settings > General > Site language: English, deactivate all plugins except Meta Box, and re-check the issue.

    You can also share the JS options of the date field, I will test the options on my end.

    #28947
    chillifish
    Participant

    You're right, I should have checked plugins. It's clashing with the Formidable Forms plugin. When I disable that the colour of the datepicker changes and the whole thing looks smarter.

    #28949
    chillifish
    Participant

    Thinking about it, there's a datepicker form on that page, which is loading the preview text for the datepicker, so I guess that's where it's picking up the styling from.

    #28957
    chillifish
    Participant

    Also, it seems to be unrelated as it still happens with the formidable plugin deactivated, but the 'save_format' setting is being ignored. This is causing issues with date interpretations.

    #28958
    chillifish
    Participant

    Settings below:

    array(
        'name'            => esc_html__( 'To date', 'textdomain' ),
        'id'          => $prefix . 'to_date',
        'desc'            => esc_html__( 'End of date range', 'textdomain' ),
        'type'            => 'date',
         // Date picker options. See here http://api.jqueryui.com/datepicker
         'js_options' => array(
                            'dateFormat'  => 'dd/mm/yy',
                            'changeMonth' => true,
                            'changeYear'  => true,
                             ),
        'save_format' => 'yy-mm-dd',
    ),
    #29049
    chillifish
    Participant

    Can anyone help me with the Date Format issue? It's causing me real problems and I need to make the site live.

    #29054
    Long Nguyen
    Moderator

    Hi,

    Can you please let me know which wrong with the setting save_format? The format of the date should be

    array(
        'name'            => esc_html__( 'To date', 'textdomain' ),
        'id'          => $prefix . 'to_date',
        'desc'            => esc_html__( 'End of date range', 'textdomain' ),
        'type'            => 'date',
         // Date picker options. See here http://api.jqueryui.com/datepicker
         'js_options' => array(
                            'dateFormat'  => 'd/m/y',
                            'changeMonth' => true,
                            'changeYear'  => true,
                             ),
        'save_format' => 'Y-m-d',
    ),

    Get more details here https://www.w3schools.com/php/func_date_date_format.asp

    #29057
    chillifish
    Participant

    Hi, yes, the save_format is 'Y-m-d', but the date is being saved as d/m/y. This is causing an issue with strtotime on the front end.

    #29074
    Long Nguyen
    Moderator

    Hi,

    The function strtotime() parse the text date time to Unix timestamp. You can use the setting 'timestamp' => true to save the timestamp value to the database. Please get more details on the documentation https://docs.metabox.io/fields/datetime/#settings

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