Hi there,
I need to get this script to be adjustable for hours based on server location (ie. I am in UK and server in USA). I think this is done with the gmdate() function but am unsure on how to implement this here. Can anyone possibly assist? I need to go back 7 hours.
<?php
function smartArchives(){
global $tableposts, $PHP_SELF;
// set the URI of your archives; this might not need to be changed (currently, it's [url]http://yoursite.com/archives/[/url])
$archive_uri = get_settings('home')."/archives/";
$now = gmdate('Y-m-d H:i:s'); // get the current GMT date
$qy = mysql_query("SELECT distinct year(post_date) as year, post_status FROM $tableposts WHERE post_status='publish' AND post_date <= CURDATE() ORDER BY year desc");
echo('<ul>'."\n");
// loop to create the small archive block with year/month links
while($years = mysql_fetch_array($qy)) {
echo('<li>'."\n");
echo('<strong><a href="'.$archive_uri.$years[year].'/">'.$years[year].'</a> : </strong> '."\n");
$qm = mysql_query("SELECT distinct month(post_date) as month, monthname(post_date) as monthn FROM $tableposts ORDER BY month asc") or die(mysql_error());
while($date = mysql_fetch_array($qm)) {
$q = mysql_query("SELECT *, year(post_date) as year, month(post_date) as month FROM $tableposts WHERE year(post_date)='$years[year]' AND month(post_date)='$date[month]' AND post_status='publish' AND post_date <= CURDATE() ORDER BY id desc") or die(mysql_error());
if(mysql_num_rows($q)) {
$sm = date("M", strtotime("$date[month]/01/2001")); // get the shortened month name
$pd = sprintf("%02s", $date[month]); // pad the month with a zero if needed
echo('<a href="'.$archive_uri.$years[year].'/'.$pd.'/">'.$sm.'</a> '."\n");
}
}
echo('</li>'."\n");
}
echo('</ul>'."\n");
$qy = mysql_query("SELECT distinct year(post_date) as year, post_status FROM $tableposts WHERE post_status='publish' AND post_date <= CURDATE() ORDER BY year desc");
// loop to display links to all posts, sorted by descending month and day
while($years = mysql_fetch_array($qy)) {
$qm = mysql_query("SELECT distinct month(post_date) as month, monthname(post_date) as monthn FROM $tableposts ORDER BY month desc") or die(mysql_error());
while($date = mysql_fetch_array($qm)) {
$q = mysql_query("SELECT *, year(post_date) as year, month(post_date) as month FROM $tableposts WHERE year(post_date)='$years[year]' AND month(post_date)='$date[month]' AND post_status='publish' AND post_date <= CURDATE() ORDER BY id desc") or die(mysql_error());
if(mysql_num_rows($q)) {
$lm = date("F", strtotime("$date[month]/01/2001")); // get the full month name
$pd = sprintf("%02s", $date[month]); // pad the month with a zero if needed
echo('<h4><a href="'.$archive_uri.$years[year].'/'.$pd.'/">'.$lm.' '.$years[year].'</a></h4>'."\n");
echo('<ul>'."\n");
$q = mysql_query("SELECT *, year(post_date) as year, month(post_date) as month FROM $tableposts WHERE year(post_date)='$years[year]' AND month(post_date)='$date[month]' AND post_status='publish' ORDER BY post_date desc") or die(mysql_error());
while($post = mysql_fetch_array($q)){
if ($post[post_date_gmt] <= $now) {
$d = date('[d] ', strtotime($post['post_date']));
echo("<li>$d<a href=\"".get_permalink($post[ID]).'">'.$post[post_title].'</a></li>'."\n");
}
}
echo ('</ul>'."\n");
}
}
}
}
Thanks so much.