Forums

Custom fields for event time: storing, displaying, and ordering by 12/24 hours (2 posts)

  1. CrowChick
    Member
    Posted 2 years ago #

    Hi there!

    I've been looking, but there is surprisingly little discussion of using custom fields for setting event times. (Even Flutter only has a date field, nothing for time!)

    I have a client who needs to post events with start and end times. Plus, we need to be able to order those events by their start times.

    My first instinct was to have the client put in the time as military/24-hour value like 14:30 for 2:30pm, then use PHP to convert that to 12hr time on the front-end in the template using code illustrated here: http://style-vs-substance.com/programming/convert-24-hour-military-time-to-12-hour-ampm-time-in-php/

    This works great, BUT, I hate making a client think about what format they are using when writing a post. Is there any way to let them input the value as 12-hour time, convert it to 24 hour time for ordering purposes only, and then display it as 12-hour time on the site?

    Any ideas? Any?

  2. MichaelH
    Volunteer
    Posted 2 years ago #

    Might look at something like http://wordpress.org/support/topic/267202 which manages a date custom field but talks about the possibility of adding time.

    Not sure plugins such as http://wordpress.org/extend/plugins/custom-field-template/ or http://wordpress.org/extend/plugins/more-fields/ which can 'assist' users with input of dates. Not sure if there are 'native' date/time fields.

    Note if you don't use military time (00:00 to 24:00) you would need another field to determine AM/PM and that adds complexity to sorting. WOuld be best if you can get a date/time field such as the wp_posts table post_date.

Topic Closed

This topic has been closed to new replies.

About this Topic