woolyg Posted February 11, 2008 Share Posted February 11, 2008 Hi all, I'm taking information from a form that defines a starting time for an advert, as follows: <?php $start_day = $_POST['ad_start_day']; $start_month = $_POST['ad_start_month']; $start_year = $_POST['ad_start_year']; $ad_start_date = $start_year."-".$start_month."-".$zero.$start_day." "."00:00:00"; ?> Now, i'd like to define $ad_end_date to be 31 days after $ad_start_date.. how do I do this? I've looked at mktime() and strtotime() but neither are very clear, and both arent working for me! Cheers, Woolyg Quote Link to comment Share on other sites More sharing options...
vbnullchar Posted February 11, 2008 Share Posted February 11, 2008 try this... <?php $e = strtotime($ad_start_date); $ad_end_date = mktime(0,0,0, date('n',$e), date('j',$e)+31, date('Y',$e) ); ?> Quote Link to comment Share on other sites More sharing options...
woolyg Posted February 11, 2008 Author Share Posted February 11, 2008 Thanks - I ended up using: <?php $start_day = $_POST['vacancy_start_day']; $start_month = $_POST['vacancy_start_month']; $start_year = $_POST['vacancy_start_year']; $vacancy_start_date = $start_year."-".$start_month."-".$zero.$start_day." "."00:00:00"; $vacancy_end_date = date("Y-m-d H:i:s", strtotime("$vacancy_start_date + 31 days")); ?> - Woolyg 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.