Title: database date output
Last modified: August 20, 2016

---

# database date output

 *  [andrewtoohill](https://wordpress.org/support/users/andrewtoohill/)
 * (@andrewtoohill)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/database-date-output/)
 * I am running a query that is pulling from the database the post_title, the post_name,
   and the post_date. I am then outputting rows with this information. However the
   date is coming out like this: 2012-11-05 22:09:13 and I need it to come out like
   this: November 5, 2012 . Here is the code:
 *     ```
       $query_y = "SELECT post_title, post_name, post_date FROM $table_name WHERE post_type='post' AND year(post_date) = '$i' AND post_status = 'publish' ORDER BY post_date DESC";
                $myrows = $wpdb->get_results($query_y);
   
                echo "<ul class='custom'>";
   
                foreach($myrows as $myrow) {
       	         $title = $myrow->post_title;
       	         $permalink = $myrow->post_name;
       	         $date = $myrow->post_date;
   
       	         echo "<li>".$date."<br /><a href='".$permalink."' title='".$title."'>".$title."</a></li>";
       ```
   

Viewing 1 replies (of 1 total)

 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/database-date-output/#post-3214684)
 * WP stores its dates as a ‘datetime’ datatype – a string in the format you are
   getting. You need to convert this string to a ‘timestamp’ which can then be converted
   to your desired format.
 * To use the default WP date format for your site, try this:
 *     ```
       $date = date_i18n(get_option('date_format'), strtotime($myrow->post_date));
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘database date output’ is closed to new replies.

## Tags

 * [post_date](https://wordpress.org/support/topic-tag/post_date/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * Last activity: [13 years, 6 months ago](https://wordpress.org/support/topic/database-date-output/#post-3214684)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
