WordPress.org

Ready to get started?Download WordPress

Forums

get_page - formatting date (2 posts)

  1. AriesCZ
    Member
    Posted 3 years ago #

    I am trying to create template which shows list of childern of current page. I am using this code

    <ul>
    <?php
    $articles = get_pages('child_of='.$post->ID.'&sort_column=post_date&sort_order=desc');
    foreach($articles as $page)
    {
    ?>
    <li><?php echo $page->post_date; ?> - <a href="<?php echo get_page_link($page->ID) ?>"><?php echo $page->post_title; ?></a></li>
    <?php
    }
    ?>
    </ul>

    However, output from this code has exact date, including seconds (for example 2011-02-01 07:55:54). Is there any way to format this date to something like "day/month/year"?

  2. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    possibly with:

    <?php echo strftime( '%d/%m/%y' , strtotime($page->post_date) ); ?>

    http://php.net/manual/en/function.strftime.php
    http://www.php.net/manual/en/function.strtotime.php

    there might be simpler solutions ...

Topic Closed

This topic has been closed to new replies.

About this Topic