WordPress.org

Ready to get started?Download WordPress

Forums

Using the_time with user-preferred date formatting? (5 posts)

  1. weefselkweekje
    Member
    Posted 5 years ago #

    I'm developing a new theme, and came across the phenomenon where the the_date template tag does not display the date more than once (mental note: add to Ideas after I post this).

    The alternative listed everywhere is to use the_time, but that requires me to decide on a single date formatting string for all users. With an earlier theme I did, people kept bugging me to change this so they could have the date displayed according to their country's conventions.

    Is there any way to 'get to' the date formatting setting under 'Settings->General' and feed the format string to the_time?

  2. Samuel Wood (Otto)
    Tech Ninja
    Posted 5 years ago #

    Errr... huh?

    If you just use the_time() then it defaults to whatever the date formatting string in Settings->General is. Just like the_date() does.

  3. weefselkweekje
    Member
    Posted 5 years ago #

    As far as I know, it'll use the formatting string under "Time format" (not "Date format"), and will display the time, not the date.

    The thing is that lots of themes show the date for every post, not as a divider between days. This is how I'd like my theme to work as well. The only way to do this is to use the_time with a hard-coded format string. For international users, this is less than ideal.

  4. Samuel Wood (Otto)
    Tech Ninja
    Posted 5 years ago #

    Ahhh, yes, I see. You want to use the date format string with the_time. Okay then. Use this:
    the_time(get_option('date_format'));

  5. weefselkweekje
    Member
    Posted 5 years ago #

    Thanks Otto :) Several entire continents will be pleased :)

Topic Closed

This topic has been closed to new replies.

About this Topic