Support » Fixing WordPress » get_the_date and get_the_time ignoring format string argument

  • Hi all,
    I have searched high and low through the codex, forums and via google and have not come up with an answer to my question.
    The problem is the following: within my theme I am in various places using get_the_date and get_the_time calls. On different pages (e.g. main page vs. page listing archives) I wish to have a different format for the date and/or time. The problem is that whatever format string I place in my get_the_date and get_the_time calls, it is ignored and always some sort of standard format is being used!
    I have tried various format strings to test and even modified some of the strings around the date and time to ensure that I am editing in the right place….which I am, but whatever date/time format string I supply, it is ignored!
    Can anyone shed some light on this for me?
    Thanks a lot in advance,
    Kristian.

Viewing 4 replies - 1 through 4 (of 4 total)
  • please post some exact codes you have tried so far;

    possibly also post the code of the full template; http://codex.wordpress.org/Forum_Welcome#Posting_Code

    Hi,
    for example….in my theme’s main page (home.php) there is the following:

    <?php while (have_posts()) : the_post(); ?>
    <li>
    <h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> <span class="meta"><?php echo(get_the_date('M j, Y')); ?> | <?php     comments_popup_link(__('No Comments', THEME_TEXTDOMAIN), __('1 Comment', THEME_TEXTDOMAIN), __('% Comments', THEME_TEXTDOMAIN)); ?    ></span></h4>


    Note: it doesn’t matter if I use the_date() or echo(get_the_date()) (or use the the_time, get_the_time functions).

    Although the format string is a valid one, it is ignored and instead the format equating to ‘l, F jS, Y’ is displayed! (and this is not even the format that I have defined in my wordpress settings for the default date format!)

    This problem is within every php page of my theme, the date/time format string is just ignored. The only way I can get around this, is to write my own function for returning the post date/time and within that function, call the mysql2date function.

    what theme are you using?

    does the problem continue if you temporarily switch to the default theme, for instance Twenty Twelve?

    also try to deactivate all plugins to see if that helps.

    Hi,
    thanks for the tip about the plugins….it turns out that it is the qTranslate plugin doing it.
    Initially I tried the twenty* themes and had the same problem, then disabled all plugins and gradually turned them on again…and it is qTranslate.
    I rely on qTranslate completely, so instead of removing (which I can’t) or modifying it (which will create problems during updates), I shall perhaps just use my own date/time function then, which then directly uses mysql2date to format exactly the way I want.

    Thanks for your advice….I should have thought about the plugins earlier!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘get_the_date and get_the_time ignoring format string argument’ is closed to new replies.