WordPress.org

Ready to get started?Download WordPress

Forums

Problem with the_time - Showing Y-m-d in browser (9 posts)

  1. poemoe
    Member
    Posted 1 year ago #

    Hi!

    I have a loop, like this:

    <?php query_posts('cat=4');?>
    <?php while (have_posts()) : the_post();?>
    <?php the_title();?>
    <?php the_time(' Y-m-d, H:i'); ?>
    <?php endwhile;?>
    <?php wp_reset_query();?>

    Im using it to make a list of recent news. The title of the news (from the_title) is showing up in the browser. But the problem is that the date, from the_time, isn't showing up as date, it's showing up as Y-m-d H:i IN THE BROWSER?!

    I have tried to place my the_time -function in other loops in my theme and in other template files, I have even tried to look at the theme in other browsers like chrome, IE9 and firefox. I get the same problem every time. I also tried to use the php function date, to show the actual date like this:

    <?php echo date(' Y-m-d, H:i'); ?>

    That works properly, showing the recent time/date.

    I have also tried to use the_time function and the_date function in wordpress without giving it any formatting characters. At that time, the function is working.

    What is wrong? Why can't I format the function the_time?

    I appriaciate your help

    /Daniel

  2. esmi
    Forum Moderator
    Posted 1 year ago #

    Change <?php the_time(' Y-m-d, H:i'); ?> to <?php the_time(); ?>

  3. poemoe
    Member
    Posted 1 year ago #

    I have done that, it gives me the formatting 11:05 (the time of the post), so with that syntax it's working, but I would like to format the_time different at different pages.

    I'm glad you wanna help, but I have already tried that :/

    I really wanna format the_time as I want it...

  4. esmi
    Forum Moderator
    Posted 1 year ago #

    Try <?php the_date('Y-m-d'); ?>, <?php the_time('H:i'); ?>

  5. poemoe
    Member
    Posted 1 year ago #

    Im sorry esmi, I have tried that also, it seems like it doesn't matter what I place between parentheses, the html does always only display whats inside the parentheses :S

  6. esmi
    Forum Moderator
    Posted 1 year ago #

    <?php the_time('Y-m-d, H:i'); ?> works fine for me. It displays the date & time - not Y-m-d, H:i.

  7. poemoe
    Member
    Posted 1 year ago #

    Yeah, I have done it many times before on other themes I've made, but this time it's not working, but I can't figure out why...

  8. esmi
    Forum Moderator
    Posted 1 year ago #

    Perhaps there's another issue in that template or theme? Or a plugin is causing a problem?

  9. poemoe
    Member
    Posted 1 year ago #

    Yes that have crossed my mind also, think I'm gonna deactivate all my plugins and see if that helps, writing here again when I've done that!

Topic Closed

This topic has been closed to new replies.

About this Topic