johnnyk Posted July 15, 2006 Share Posted July 15, 2006 Is there an easy way to get the date of next Sunday (or Monday or whatever).I'm thinking I could use a conditional to determine what day it is currently, and add seconds accordingly, then use adjusted date function - but is there anything better that I can do using PHP or MySQL functions? Quote Link to comment https://forums.phpfreaks.com/topic/14649-next-sunday/ Share on other sites More sharing options...
kenrbnsn Posted July 15, 2006 Share Posted July 15, 2006 try:[code]<?php echo date('F j, Y',strtotime('next Sunday')); ?>[/code]or[code]<?php echo date('F j, Y',strtotime('this Sunday')); ?>[/code]Sometimes PHP thinks that "this Sunday" and "next Sunday" are different, so see which one works for you.Ken Quote Link to comment https://forums.phpfreaks.com/topic/14649-next-sunday/#findComment-58355 Share on other sites More sharing options...
hvle Posted July 15, 2006 Share Posted July 15, 2006 next sunday and this sunday are different Quote Link to comment https://forums.phpfreaks.com/topic/14649-next-sunday/#findComment-58356 Share on other sites More sharing options...
pixy Posted July 15, 2006 Share Posted July 15, 2006 Couldn't you use ADDDATE() and SUBBDATE()--or are those only usable in mysql? Quote Link to comment https://forums.phpfreaks.com/topic/14649-next-sunday/#findComment-58357 Share on other sites More sharing options...
johnnyk Posted July 15, 2006 Author Share Posted July 15, 2006 Thanks alot kenrbnsn. But what do you mean about the this Sunday and next Sunday thing?pixy, that's just MySQL, and they would only work if I determine what day it currently is first.Also, is there a way to get 2 sundays from now. I'm using MySQL to select anything that is in between the upcoming sunday and a week from that (or "Sunday to a week from Sunday"). I don't need the SQL or anything, but how would I get "a week from Sunday" using strtotime()? Quote Link to comment https://forums.phpfreaks.com/topic/14649-next-sunday/#findComment-58364 Share on other sites More sharing options...
AndyB Posted July 15, 2006 Share Posted July 15, 2006 [quote author=johnnyk link=topic=100641.msg397535#msg397535 date=1152936664]Also, is there a way to get 2 sundays from now....but how would I get "a week from Sunday" using strtotime()?[/quote]I'd look at the date() and strtotime() functions in the manual. This is php help, not php helpless :) Quote Link to comment https://forums.phpfreaks.com/topic/14649-next-sunday/#findComment-58369 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.