DonPatricio Posted February 3, 2008 Share Posted February 3, 2008 I got this date in my DB: 2008-02-04 00:12:22 I want to output this value - 8 hours. How do i do that. I tried this, but that obviously doesn't work: $date = mysql_query ("SELECT date from date_test;"); while ($date_output = mysql_fetch_array ($date)) { $date1 = $date_output[date] - (8*60); echo $date1 . "<br>"; } Quote Link to comment https://forums.phpfreaks.com/topic/89275-solved-time-conversion/ Share on other sites More sharing options...
CerealBH Posted February 3, 2008 Share Posted February 3, 2008 <?php $nextWeek = time() + (7 * 24 * 60 * 60); // 7 days; 24 hours; 60 mins; 60secs echo 'Now: '. date('Y-m-d') ."\n"; echo 'Next Week: '. date('Y-m-d', $nextWeek) ."\n"; // or using strtotime(): echo 'Next Week: '. date('Y-m-d', strtotime('+1 week')) ."\n"; ?> that should be helpful foudn at link below http://us3.php.net/manual/en/function.time.php Quote Link to comment https://forums.phpfreaks.com/topic/89275-solved-time-conversion/#findComment-457133 Share on other sites More sharing options...
DonPatricio Posted February 3, 2008 Author Share Posted February 3, 2008 i don't really see how this can help me with my prob. Quote Link to comment https://forums.phpfreaks.com/topic/89275-solved-time-conversion/#findComment-457145 Share on other sites More sharing options...
DonPatricio Posted February 3, 2008 Author Share Posted February 3, 2008 any other suggestion how to output 2008-02-04 00:12:22 -8 hours. The date is already formatted in the DB so that's why I don't know how to do that. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/89275-solved-time-conversion/#findComment-457152 Share on other sites More sharing options...
PFMaBiSmAd Posted February 4, 2008 Share Posted February 4, 2008 Do it in the query using the mysql date_sub() function - http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date-sub Quote Link to comment https://forums.phpfreaks.com/topic/89275-solved-time-conversion/#findComment-457162 Share on other sites More sharing options...
DonPatricio Posted February 4, 2008 Author Share Posted February 4, 2008 thanks Quote Link to comment https://forums.phpfreaks.com/topic/89275-solved-time-conversion/#findComment-457169 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.