WordPress.org

Ready to get started?Download WordPress

Forums

Sidebar Archives Date Format (5 posts)

  1. Yawnster
    Member
    Posted 8 years ago #

    Ive been trying to do this for a while now, the date format on my sidebar is.. eg. "December 2005"..

    How would I change that to "Dec 05"?

    Thanks. Alex

  2. Orin
    Member
    Posted 8 years ago #

    You would change the value of the_date or the_time to be from:

    the_date('F Y')

    to more like:

    the_date('M y')

    Here's the codex article explaining it. Here's the full syntax.

  3. Yawnster
    Member
    Posted 8 years ago #

    Hey bud, thanks for the reply. I dont quite think I structured the question correctly.

    My Sidebar uses the function wp_get_archives(). I did a little digging, in that function it queries the post table and then returns the post_date as a month.. the line is..

    wp-includes/template-functions-general.php. Line 333.

    $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS year, MONTH(post_date) AS month, count(ID) as posts FROM $wpdb->posts WHERE post_date < '$now' AND post_date != '0000-00-00 00:00:00' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit);

    from this i can see a function MONTH() around the post_date.. does anyone know where this function is defined because if im reading correctly it take the integer value from the database and converts it into the String value that it displays through the $text variable.

    Thanks Alex.

  4. Orin
    Member
    Posted 8 years ago #

    Oh good lord — you turned a question I thought I could answer easy into a quest...

    Ok, what I've deduced from the amazing PHP WordPress Cross Reference is that MONTH(), though it looks like a function, is not. It's actually part of an array that's pulling MySQL queries. My basis for such a hypothesis: $wpdb->get_results(... and the fact that the commands are all in CAPS. $wpdb is defined in wp-includes/wpdb.php and has everything to do with talking to MySQL.

    Hope this explains it, but bear in mind I am not a PHP expert. It's just incredible what a little color-coding will do.

    And hey, what was wrong with the_date('M y') in the first place? :-P

  5. skulled
    Member
    Posted 8 years ago #

    To clarify and extend on Orin's reply ..

    MONTH() is sort of a function, not in PHP or WordPress .. but a MySQL routine if you will ..

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.