Custom Fields
Re-Envisioned
Support General Displaying Time Data

  • Creator
    Topic
  • #14787
    @mindspark
    Participant

    the default behavior for the time fields is 24 hour time. how to convert to 12 hour display on the front end?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
    Replies
  • #14820
    @mindspark
    Participant

    anyone have any idea about this? I need 12h format, not 24h

    thx

    #14823
    Anh Tran
    Keymaster

    Hi Neil,

    You can convert the format using PHP date() function. Assuming your time has format “04:20 PM”, and you want to convert to “16:20”, here is the code:

    $time = rwmb_meta( 'field_id' ); // 04:20 PM
    echo date( 'H:i', strtotime( $time ) ); // 16:20

    See more answers here.

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