newburcj Posted April 22, 2010 Share Posted April 22, 2010 I have a form with two text fields: Date the show will open: $_POST['vdate'] (not the current date) and Number of performances: $_POST['shows'] vdate is entered in the format 'yyyy-mm-dd'. I would like to take the original vdate, enter its value into a MySQL field, and increment the date by one day in a loop until the value of shows is reached. The loop isn't my problem. I can't seem to increment the date within the loop. There's a lot of date functions within php but none of them seem to be able to do this simple addition: newdate = date + 1 day. Help would be appreciated as I'm totally stuck. Thanks! Link to comment https://forums.phpfreaks.com/topic/199347-incrementing-an-entered-date/ Share on other sites More sharing options...
Deoctor Posted April 22, 2010 Share Posted April 22, 2010 so by all means u want to increase the date by one day. haven't u read the mysql documentation about date SELECT DATE_ADD(CURDATE(), INTERVAL 1 DAY); Link to comment https://forums.phpfreaks.com/topic/199347-incrementing-an-entered-date/#findComment-1046248 Share on other sites More sharing options...
newburcj Posted April 23, 2010 Author Share Posted April 23, 2010 Thank you, but I wish to increment the date using PHP. Link to comment https://forums.phpfreaks.com/topic/199347-incrementing-an-entered-date/#findComment-1047044 Share on other sites More sharing options...
newburcj Posted April 24, 2010 Author Share Posted April 24, 2010 I finally figured out the code needed: <?php $TZ = date_default_timezone_set("America/New_York"); \\ if not already set. $oldate = '2010-05-10'; $dd = strtotime($oldate) + 86400; $newdate = date("Y-m-d",$dd); \\ newdate becomes '2010-05-11' ? Thanks! Link to comment https://forums.phpfreaks.com/topic/199347-incrementing-an-entered-date/#findComment-1047512 Share on other sites More sharing options...
oni-kun Posted April 24, 2010 Share Posted April 24, 2010 I finally figured out the code needed: <?php $TZ = date_default_timezone_set("America/New_York"); \\ if not already set. $oldate = '2010-05-10'; $dd = strtotime($oldate) + 86400; $newdate = date("Y-m-d",$dd); \\ newdate becomes '2010-05-11' ? Thanks! $newdate = strtotime('2010-05-10' . " +1 days"); Link to comment https://forums.phpfreaks.com/topic/199347-incrementing-an-entered-date/#findComment-1047515 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.