configuring the timestamp within a plugin's function (6 posts)

  1. amory
    Posted 11 years ago #

    I'm developing a widget for WP-Dash that will display all upcoming concerts (the scheduled entries div from the existing dashboard) and need help configuring the timestamp.

    Here is the main output code:
    $output .= "<li><a href='post.php?action=edit&amp;post=$post->ID' title='edit this post'>$post->post_title</a> on $post->post_date </li>";
    For now I have the $post->post_date because it has been the only thing to actually work. I would like to be able to configure it to display as a php date format such as ('m/d/Y')

  2. Joshua Sigar
    Posted 11 years ago #

    If you do ...
    setup_postdata( $post )
    ..beforehand, you could, then do...
    the_date( 'm/d/Y' )

  3. Alex Mills (Viper007Bond)
    Posted 11 years ago #

    Would date('m/d/y', $post->post_date); not work?

    And a lot easier solution to this is to just make a copy of the "Recent Posts" widget (dashboard-recent-posts.php) and edit the post query to something like:

    SELECT ID, post_title, post_author FROM $wpdb->posts WHERE post_status = 'publish' AND post_date_gmt > '$today' ORDER BY post_date ASC LIMIT 10

    That'll list out up to the 10 soonest posts from the future with the soonest first.

    Then just change the function names and the make_widget_available part at the bottom and you're good to go.

  4. amory
    Posted 11 years ago #

    Thanks for the replies, I'll try in the morning. @viper - i'm looking to display the date as well as sort by it so the second part is already taken care of.


  5. Alex Mills (Viper007Bond)
    Posted 11 years ago #

    That is ordered by date and adding the date would be easy, but whatever. :)

  6. amory
    Posted 11 years ago #

    Sorry - long night last night... I meant that the upcoming posts are already sorted, and just need timestamps per each. With the date() function, the timestamps for each are 12/31/1969.

    Code with the_time() - http://paste.uni.cc/7556
    Code with date() - http://paste.uni.cc/7555

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.