Roq Posted April 8, 2008 Share Posted April 8, 2008 I'm running some SQL queries that are based off of having a start date and an end date. I need the date in the format of date(Y-m-d), or something like 2008-04-08 (today's date, april 8th, 2008). The problem I have is I need to also get the date 3 days from today in the same format. Just adding to the day obviously has the problem of not rolling over on months end, so what is the 'proper' way for getting this information? Quote Link to comment https://forums.phpfreaks.com/topic/100160-solved-datey-m-d-3-days/ Share on other sites More sharing options...
discomatt Posted April 8, 2008 Share Posted April 8, 2008 I'm assuming you want the date to be echo'ed ? echo date('Y-m-d', time() + 3*24*60*60); Quote Link to comment https://forums.phpfreaks.com/topic/100160-solved-datey-m-d-3-days/#findComment-512109 Share on other sites More sharing options...
Roq Posted April 8, 2008 Author Share Posted April 8, 2008 Actually I just need to store it as a variable to use in my SQL query. Basically this report will be run every friday and will automatically email out any change management tickets that are scheduled to be performed over the next 3 days (or, the weekend + Monday). Quote Link to comment https://forums.phpfreaks.com/topic/100160-solved-datey-m-d-3-days/#findComment-512115 Share on other sites More sharing options...
Roq Posted April 8, 2008 Author Share Posted April 8, 2008 Oh sorry what you said worked perfectly by the way just setting it to a variable instead of Echo. Thanks for the fast response!!!!! Quote Link to comment https://forums.phpfreaks.com/topic/100160-solved-datey-m-d-3-days/#findComment-512118 Share on other sites More sharing options...
kenrbnsn Posted April 8, 2008 Share Posted April 8, 2008 I would use the strtotime() function: <?php echo 'Three days from today: ' . date('Y-m-d',strtotime('+3 days')); ?> Quote Link to comment https://forums.phpfreaks.com/topic/100160-solved-datey-m-d-3-days/#findComment-512120 Share on other sites More sharing options...
Roq Posted April 8, 2008 Author Share Posted April 8, 2008 Thanks again guys, both of you Quote Link to comment https://forums.phpfreaks.com/topic/100160-solved-datey-m-d-3-days/#findComment-512122 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.