wmguk Posted May 29, 2008 Share Posted May 29, 2008 Hey guys, The discount field holds the amount of weeks that the discount applies for. I'm going to create a script and what I need to is: get today's date. check field 'discount' (will be 3 or 4 or something like that) add the result to todays date and then run an update script to input the date to my database in date field 'discdate' I can get todays date, and i can do the update but I have googled and I cant seem to get a definate answer, how can i add 4 weeks to the date? Link to comment https://forums.phpfreaks.com/topic/107764-solved-advice-on-adding-x-days-to-a-date/ Share on other sites More sharing options...
thebadbad Posted May 29, 2008 Share Posted May 29, 2008 <?php //2008-05-29 $today = date('Y-m-d'); //4 weeks $discount = '4'; //add $discdate = date('Y-m-d', strtotime("$today +$discount weeks")); echo $discdate; //2008-06-26 ?> Link to comment https://forums.phpfreaks.com/topic/107764-solved-advice-on-adding-x-days-to-a-date/#findComment-552382 Share on other sites More sharing options...
wmguk Posted May 29, 2008 Author Share Posted May 29, 2008 wow, you have done the whole thing for me!! Thank you I wasnt sure if you could just add +4 or how to do it. Thank you again Link to comment https://forums.phpfreaks.com/topic/107764-solved-advice-on-adding-x-days-to-a-date/#findComment-552383 Share on other sites More sharing options...
thebadbad Posted May 29, 2008 Share Posted May 29, 2008 Already had an example laying around, so why not post it Link to comment https://forums.phpfreaks.com/topic/107764-solved-advice-on-adding-x-days-to-a-date/#findComment-552392 Share on other sites More sharing options...
thebadbad Posted May 29, 2008 Share Posted May 29, 2008 And BTW, please mark the topic as solved. Link to comment https://forums.phpfreaks.com/topic/107764-solved-advice-on-adding-x-days-to-a-date/#findComment-552395 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.