Time formatting question

Home Forums Calendar Products Events Calendar PRO Time formatting question

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #25918
    Shawn
    Participant

    I’m having a problem getting the time formatted the way I want. I’ve duplicated the “table.php” file into an “events” directory in my theme, and have modified the event time to use this code:
    date_i18n( get_option( ‘time_format’, ‘g:ia’ ), $start)

    The problem is that it’s not respecting the “g:ia” format; I’m getting it formatted like g:i a (e.g. 8:00 am instead of 8:00am).
    I’ve tried switching themes to no effect.
    Any ideas?

    #25919
    Shawn
    Participant

    Never mind – I figured out that I could use

    tribe_get_start_date(null, false, ‘g:ia’);

    instead.

    Why are there two different methods used to output the event start and end times in the plugin? Just curious…

    #25925
    Barry
    Member

    Hi Shawn. When you use get_option() you are specifying a piece of information you wish to receive and – just in case that piece of information doesn’t exist – you are also specifying a default or fall back value.

    So get_option(‘time_format’, ‘g:ia’) will not return ‘g:ia’ unless 1) the WordPress time_format setting doesn’t exist in the database, which would be very unusual, or 2) time_format itself is set to ‘g:ia’ (this can be controlled via the WordPress settings admin pages).

    You’re correct that different methods are used within the plugins – there is no official answer for that, it really depends on a mixture of things such as the context, the programming style of the developer who committed that piece of code and so on.

    Of course we try for a high level of consistency but now and again these things might get away from us.

    I hope that answers your questions and just let me know if you need any further support 🙂

    #25928
    Shawn
    Participant

    Ahh, got it. Thanks for the answer, Barry!

    #25932
    Barry
    Member

    No problem!

    #977880
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Time formatting question’ is closed to new replies.