Displaying Time Data

Support General Displaying Time Data

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #14787
    @mindspark@mindspark
    Participant

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

    #14820
    @mindspark@mindspark
    Participant

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

    thx

    #14823
    Anh TranAnh 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 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.