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 Link to comment https://forums.phpfreaks.com/topic/90431-defining-a-datetime-31-days-in-the-future/ 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) ); ?> Link to comment https://forums.phpfreaks.com/topic/90431-defining-a-datetime-31-days-in-the-future/#findComment-463647 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 Link to comment https://forums.phpfreaks.com/topic/90431-defining-a-datetime-31-days-in-the-future/#findComment-463661 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.