• I want to extract some data from my WP db but the data isn’t being used in a wordpress template so I can’t use WP tags. I want to use the post_date value from wp_posts but it comes out “2004-03-13 17:28:38” and this isn’t the formatting I want. This is the code I’m using :
    $post_date=$myrow["post_date"];
    How do I apply date formatting to it so it looks like “13/03/04”. BTW, I don’t want the formatting I just want to know how to apply it.
    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • $post_date = date(‘date_format_here’, strtotime($post->post_date));

    Go into admin / options.

    Thread Starter shelaghg

    (@shelaghg)

    Root – the whole point of the question is that I’m not using the data in WordPress!
    codergurl – that seems on the right track but it displays all the dates as 07/25/2004 12:00:00 AM !

    Thread Starter shelaghg

    (@shelaghg)

    codergurl – the following worked :
    $post_date = date('m/d/Y h:i:s A', strtotime($myrow["post_date"]));
    Thanks for putting me on to strtotime – that was just what I needed ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Date Formatting’ is closed to new replies.