Pages

Saturday, March 31, 2012

how to get update time of wordpress blog

This bit of code will do it:
<?php
$update = get_posts('numberposts=1');
$postdate = $update[0]->post_date;
$postdategmt = $update[0]->post_date_gmt;
echo 'Updated: ' .
mysql2date('g:j a T ', $postdate) .
mysql2date('(g:j), ', $postdategmt) .
mysql2date('F j, Y', $postdate);
?>

This is dependent on the server, so you may have to finnagle the T format string (in 'g:j a T ') if you and your web site's server are not in the same time zone.

No comments:

Post a Comment

Thank you for your Comment....