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 Link to comment https://forums.phpfreaks.com/topic/55533-how-do-you-add-7-days-to-now/ 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 Link to comment https://forums.phpfreaks.com/topic/55533-how-do-you-add-7-days-to-now/#findComment-274408 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); ?> Link to comment https://forums.phpfreaks.com/topic/55533-how-do-you-add-7-days-to-now/#findComment-274410 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? Link to comment https://forums.phpfreaks.com/topic/55533-how-do-you-add-7-days-to-now/#findComment-274436 Share on other sites More sharing options...
twilightnights Posted June 14, 2007 Author Share Posted June 14, 2007 also tried add_weeks Link to comment https://forums.phpfreaks.com/topic/55533-how-do-you-add-7-days-to-now/#findComment-274627 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) Link to comment https://forums.phpfreaks.com/topic/55533-how-do-you-add-7-days-to-now/#findComment-274749 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); ?> Link to comment https://forums.phpfreaks.com/topic/55533-how-do-you-add-7-days-to-now/#findComment-274788 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) Link to comment https://forums.phpfreaks.com/topic/55533-how-do-you-add-7-days-to-now/#findComment-274834 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.