SharkBait Posted March 7, 2007 Share Posted March 7, 2007 Hi, I've been working with the following code for someone: <?php $news = mysql_query("SELECT *, DATE_FORMAT(NewsDate, '%m-%d-%Y %H:%i:%s') as myDate FROM News ORDER BY NewsDate DESC LIMIT 8") or die ("cant get em"); while($rows=mysql_fetch_array($news)){ $title=$rows["NewsTitle"]; $content=$rows["NewsText"]; $date = date('m-d-Y H:i s', strtotime($rows['myDate']) + 3600); $author=$rows["author"]; ?> But what is happening when I echo $date it shows up at 11-23-2008 22:45:00. It should read 03-06-2007 22:45:00. When I run the MySQL Query by itself within phpMyAdmin it returns the proper value for it which would be 03-06-2007 21:45:00. Now when I run <?php echo date('m-d-Y H:i:s', strtotime('2007-03-06 22:45:00') + 3600); ?> Locally it works fine.. but when the script runs on the remote location it doesnt work properly. I add 1 hour to compensate for the server being behind an hour (there is no control over server time due to it being a free webhost). Any ideas?? Thanks! Quote Link to comment Share on other sites More sharing options...
btherl Posted March 7, 2007 Share Posted March 7, 2007 If you're planning to feed the time into strtotime(), you should avoid m-d-Y format. Try Y-m-d format instead. It's much more computer friendly Make the change in your mysql query. You can reformat the date to m-d-Y later when you call date() in php. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.