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 Link to comment https://forums.phpfreaks.com/topic/77321-solved-earlier-date/ 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); ?> Link to comment https://forums.phpfreaks.com/topic/77321-solved-earlier-date/#findComment-391481 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 Link to comment https://forums.phpfreaks.com/topic/77321-solved-earlier-date/#findComment-391512 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 Link to comment https://forums.phpfreaks.com/topic/77321-solved-earlier-date/#findComment-391789 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 Link to comment https://forums.phpfreaks.com/topic/77321-solved-earlier-date/#findComment-391805 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 Link to comment https://forums.phpfreaks.com/topic/77321-solved-earlier-date/#findComment-392243 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.