PDA

View Full Version : Format modified date for search results


jerrywin5
03-22-2004, 10:20 PM
Just getting going with PHPDig. It is great. I have a few questions to ask and I'll start with this one.

How can I format the date that is displayed in the search results via <phpdig:update_date/> so that it displays a format such as Mar 22, 2004?

In includes/config.php I see:
define('PHPDIG_DATE_FORMAT','\1-\2-\3'); // Date format for last update
but this modifies the order of the display rather than the format. In libs/search_function.php I also see

'update_date' => ereg_replace('^([0-9]{4})([0-9]{2})([0-9]{2}).*',PHPDIG_DATE_FORMAT,$content['last_modified']),
but haven’t delved into regular expressions yet so am lost. Any help would be appreciated.

Thanks,
Jerry

Charter
03-23-2004, 01:45 AM
Hi. Perhaps try the following.

In search_function.php replace:

'update_date' => ereg_replace('^([0-9]{4})([0-9]{2})([0-9]{2}).*',PHPDIG_DATE_FORMAT,$content['last_modified']),

with the following:

'update_date' => date("l dS of F Y h:i:s A",strtotime(substr($content['last_modified'],0,8)." ".substr($content['last_modified'],8,2).":".substr($content['last_modified'],10,2).":".substr($content['last_modified'],12,2))),

Then look at the date (http://www.php.net/manual/en/function.date.php) function and change "l dS of F Y h:i:s A" into whatever format you want.

Remember to remove any "word" wrapping in the above code.