dmirsch Posted May 2, 2012 Share Posted May 2, 2012 I have the following code: //DETERMINES ASL POLICY if ($perfRow['ASL']=='ToArrange'){ $ASLdate = $perfRow['startDateTime']; $ASLconfirm = strtotime($ASLdate-'21 days'); echo "<!--[ASL=ToARRANGE--><p>An ASL Interpreted performance of this event is offered on".date("l, F j",strtotime($perfRow['startDateTime']))." at ".date("g:i a",strtotime($perfRow['startDateTime'])).".<br />Please contact me by ".date("l, F j",strtotime($ASLconfirm))." to confirm this service.</p>"; } What I need is that if the ASL is "To be Arranged" there is a date that lists for $ASLconfirm that is three weeks prior to $ASLdate. The code above gives me the following: An ASL Interpreted performance of this event is offered on Friday, September 28 at 7:30 pm. Please contact me by Wednesday, December 31 to confirm this service. As you can see from the output the December date is NOT three weeks prior to the September date. Where did I go wrong in my coding? Quote Link to comment https://forums.phpfreaks.com/topic/261927-how-do-i-subtract-3-weeks-from-a-variable/ Share on other sites More sharing options...
marcus Posted May 2, 2012 Share Posted May 2, 2012 $ASLconfirm = date("l, F j", strtotime($ASLdate) - 1814400); Quote Link to comment https://forums.phpfreaks.com/topic/261927-how-do-i-subtract-3-weeks-from-a-variable/#findComment-1342173 Share on other sites More sharing options...
dmirsch Posted May 2, 2012 Author Share Posted May 2, 2012 YEAH! Thanks -- that worked, but can you now tell my why "1814400"? Quote Link to comment https://forums.phpfreaks.com/topic/261927-how-do-i-subtract-3-weeks-from-a-variable/#findComment-1342175 Share on other sites More sharing options...
marcus Posted May 2, 2012 Share Posted May 2, 2012 1814400 = 3600 * 24 * 21 = 3 weeks in seconds. Quote Link to comment https://forums.phpfreaks.com/topic/261927-how-do-i-subtract-3-weeks-from-a-variable/#findComment-1342176 Share on other sites More sharing options...
dmirsch Posted May 2, 2012 Author Share Posted May 2, 2012 Thanks mgallforever! Quote Link to comment https://forums.phpfreaks.com/topic/261927-how-do-i-subtract-3-weeks-from-a-variable/#findComment-1342177 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.