rsammy Posted November 14, 2007 Share Posted November 14, 2007 i need to find a date 15 dates from today. how do i do this? i have this code: if (empty($m2)&& empty($d2) && empty ($y2)) { $datez="0000-00-00"; } and i use this $datez in my query. but how do i make this $datez to reflect 15 days earlier from todays date? thanx Quote Link to comment Share on other sites More sharing options...
harristweed Posted November 14, 2007 Share Posted November 14, 2007 <?php $calc_date = mktime(0, 0, 0, date("m"), date("d")-15, date("Y")); $datez=date("Y-m-d",$calc_date); ?> Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted November 14, 2007 Share Posted November 14, 2007 Or you can use the strtotime() function: <?php $datez = date('Y-m-d',strtotime('today -15 days')); echo $datez; ?> Ken Quote Link to comment Share on other sites More sharing options...
rsammy Posted November 14, 2007 Author Share Posted November 14, 2007 thanx for ur replies. now i have another question. i am using a pre-determined date - say 10/30/2007 as the value for $datez. how can i get this to reflect to 15 days earlier($datez should now hold a date that is 15 days older than 10/30/2007). help wud be greatly appreciated. thanx again Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted November 14, 2007 Share Posted November 14, 2007 <?php $datez = '10/30/2007'; $datez = date('Y-m-d',strtotime($datez . ' -15 days'); echo $datez; ?> Ken Quote Link to comment Share on other sites More sharing options...
rsammy Posted November 15, 2007 Author Share Posted November 15, 2007 thanx a lot! appreciate ur help - it works. topic solved 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.