twilightnights Posted June 14, 2007 Share Posted June 14, 2007 Can't find a tut on it can anyone help me? How do you add 7 days to the now() function stored in database as 00-00-00 00:00:00 Quote Link to comment Share on other sites More sharing options...
btherl Posted June 14, 2007 Share Posted June 14, 2007 If you're dealing with datetimes, you can use these: http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-add Quote Link to comment Share on other sites More sharing options...
Lumio Posted June 14, 2007 Share Posted June 14, 2007 <?php $timestamp = time(); //the same as now() $timestamp += 7*24*60*60; //adding 7 days in seconds echo date('r', $timestamp); ?> Quote Link to comment Share on other sites More sharing options...
twilightnights Posted June 14, 2007 Author Share Posted June 14, 2007 If you're dealing with datetimes, you can use these: http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-add Ok I tried that but I can't get this to work.. $query7 = "UPDATE `tool` SET DueDate='DATE_ADD(now(),INTERVAL 7 DAYS)' WHERE ToolID='$Tool1'"; am I butchering the syntax? Quote Link to comment Share on other sites More sharing options...
twilightnights Posted June 14, 2007 Author Share Posted June 14, 2007 also tried add_weeks Quote Link to comment Share on other sites More sharing options...
Nhoj Posted June 14, 2007 Share Posted June 14, 2007 Not very good with date / time (I prefer UNIX_TIMESTAMP()'s) but it seems to me you're using ,INTERVAL 7 DAYS) When you should be using ,INTERVAL 7 DAY) Quote Link to comment Share on other sites More sharing options...
Lumio Posted June 14, 2007 Share Posted June 14, 2007 I do it like that: <?php $timestamp = time(); //the same as now() $timestamp += 7*24*60*60; //adding 7 days in seconds $sql = "UPDATE `table` SET `column` = ".$timestamp.";"; $result = mysql_query($sql); ?> Quote Link to comment Share on other sites More sharing options...
Wildbug Posted June 14, 2007 Share Posted June 14, 2007 mysql> SELECT NOW(),NOW() + INTERVAL 7 DAY; +---------------------+------------------------+ | NOW() | NOW() + INTERVAL 7 DAY | +---------------------+------------------------+ | 2007-06-14 15:37:39 | 2007-06-21 15:37:39 | +---------------------+------------------------+ 1 row in set (0.00 sec) 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.