Page 1 of 1

Date formating after grabbing content by page id

Posted: Wed Sep 30, 2009 2:00 pm
by Timredd
Hi there,

I have been searching high and low for the solution to this,

I have a problem concerning formatting a date that I grab to post on a homepage that represents the last time a news page was updated.

It shows as "2009-09-29 01:35:42" which, I believe is the default format for post_modified in my mysql database.

I need it to be formatted something like this "29 September 2009".

As you can see, I am very new to all this stuff,

Anyway here is the function I am using:


<?php
if(!function_exists('getPageContent'))
{
function getPageContent($pageId)
{
if(!is_numeric($pageId))
{
return;
}
global $wpdb;
$sql_query = 'SELECT DISTINCT * FROM ' . $wpdb->posts .
' WHERE ' . $wpdb->posts . '.ID=' . $pageId;
$posts = $wpdb->get_results($sql_query);
if(!empty($posts))
{
foreach($posts as $post)
{
return nl2br($post->post_modified);
}
}
}
}
?>


Then I call it on the homepage like this:

The <a href="<?php echo get_page_link('9') ?>">news</a> page was updated on <a href="<?php echo get_page_link('9') ?>"><?php echo getPageContent(9); ?></a> .

If anybody could please help me with this problem I would be very grateful,


thank you.

Re: Date formating after grabbing content by page id

Posted: Fri Oct 02, 2009 2:58 pm
by akuji36
Hello

Take a look at the following link:

http://bytes.com/topic/php/answers/1063 ... ime-format

thanks

Rod
webpagesofease.com