Jump to content

Archived

This topic is now archived and is closed to further replies.

johnnyk

Next Sunday

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
next sunday and this sunday are different

Share this post


Link to post
Share on other sites
Couldn't you use ADDDATE() and SUBBDATE()--or are those only usable in mysql?

Share this post


Link to post
Share on other sites
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()?

Share this post


Link to post
Share on other sites
[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 :)

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.