magicked
1-13-05, 01:25 PM
I noticed today that the dates for posts on my site are suddenly incorrect (It's a blog). I have always used a date with the NOW() function of mySQL and stored the dates of each post in my database. So, the first thing I did was check to see if the database data had changed for some reason... the dates are correct in the database.
I have not changed any of my code in a long time (so it should be unrelated), so I am curious to see if there was an upgrade to mySQL or PHP that has changed the way things are processed. Here is a code sample to show how I process the date after I run the mySQL query:
$date = $row['date'];
$date = convert_date($date);
$date = date("<b>F j, Y \A.\D.<\/b> \a\\t <b>g:i A E\S\T<\/b>", $date);
print($date);
function convert_date( $date ) {
$year = substr($date, 0, 4);
$month = substr($date, 4, 2);
$day = substr($date, 6, 2);
$hour = substr($date, 8, 2);
if ($hour <= 21) {
$hour = $hour + 3;
} else {
$hour = $hour - 20;
}
$minute = substr($date, 10, 2);
$seconds = substr($date, 12, 2);
$timestamp = mktime($hour, $minute, $seconds, $month, $day, $year);
return $timestamp;
}
Thanks in advance!
I have not changed any of my code in a long time (so it should be unrelated), so I am curious to see if there was an upgrade to mySQL or PHP that has changed the way things are processed. Here is a code sample to show how I process the date after I run the mySQL query:
$date = $row['date'];
$date = convert_date($date);
$date = date("<b>F j, Y \A.\D.<\/b> \a\\t <b>g:i A E\S\T<\/b>", $date);
print($date);
function convert_date( $date ) {
$year = substr($date, 0, 4);
$month = substr($date, 4, 2);
$day = substr($date, 6, 2);
$hour = substr($date, 8, 2);
if ($hour <= 21) {
$hour = $hour + 3;
} else {
$hour = $hour - 20;
}
$minute = substr($date, 10, 2);
$seconds = substr($date, 12, 2);
$timestamp = mktime($hour, $minute, $seconds, $month, $day, $year);
return $timestamp;
}
Thanks in advance!