Jump to content


Photo

Next Sunday


  • Please log in to reply
5 replies to this topic

#1 johnnyk

johnnyk
  • Members
  • PipPipPip
  • Advanced Member
  • 126 posts

Posted 15 July 2006 - 03:45 AM

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?
Rediscover the Web:
<a href="http://www.spreadfir...;t=219"></a><br />

#2 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 15 July 2006 - 03:52 AM

try:
<?php echo date('F j, Y',strtotime('next Sunday')); ?>
or
<?php echo date('F j, Y',strtotime('this Sunday')); ?>
Sometimes PHP thinks that "this Sunday" and "next Sunday" are different, so see which one works for you.

Ken


#3 hvle

hvle
  • Members
  • PipPipPip
  • Advanced Member
  • 667 posts
  • Locationmelbourne, Australia

Posted 15 July 2006 - 03:54 AM

next sunday and this sunday are different
Life's too short for arguing.

#4 pixy

pixy
  • Members
  • PipPipPip
  • Advanced Member
  • 295 posts

Posted 15 July 2006 - 03:54 AM

Couldn't you use ADDDATE() and SUBBDATE()--or are those only usable in mysql?

This is a .44 Caliber Loveletter straight through my heart.

Tabulas + Threadless + Hire Me!


#5 johnnyk

johnnyk
  • Members
  • PipPipPip
  • Advanced Member
  • 126 posts

Posted 15 July 2006 - 04:11 AM

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()?
Rediscover the Web:
<a href="http://www.spreadfir...;t=219"></a><br />

#6 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 15 July 2006 - 04:25 AM

Also, is there a way to get 2 sundays from now....but how would I get "a week from Sunday" using strtotime()?


I'd look at the date() and strtotime() functions in the manual.  This is php help, not php helpless :)
Legend has it that reading the manual never killed anyone.
My site




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users