RE: [PHP] Last Sunday in September?

2006-02-17 Thread Shaunak Kashyap
$currentTS = strtotime("now");
$currentYear = date("Y");
$nextYear = $currentYear + 1;

$lastSundayInSepCurrentYearTS = strtotime("last Sunday",
strtotime("10/1/$currentYear"));

$firstDayNextYearTS = strtotime("1/1/$nextYear");

//
// So your psuedocode becomes...
//
if (($currentTS > $lastSundayInSepCurrentYearTS) &&
($currentTS < $firstDayNextYearTS)) {

$year++;

}

Shaunak Kashyap
 
Senior Web Developer
WPT Enterprises, Inc.
5700 Wilshire Blvd., Suite 350
Los Angeles, CA 90036
 
Main: 323.330.9900
 
www.worldpokertour.com
 
Confidentiality Notice:  This e-mail transmission (and/or the 
attachments accompanying) it may contain confidential information 
belonging to the sender which is protected.  The information is 
intended only for the use of the intended recipient.  If your are not 
the intended recipient, you are hereby notified that any disclosure, 
copying, distribution or taking of any action in reliance on the 
contents of this information is prohibited. If you have received this 
transmission in error, please notify the sender by reply e-mail and 
destroy all copies of this transmission.
-Original Message-
From: Jay Paulson [mailto:[EMAIL PROTECTED] 
Sent: Friday, February 17, 2006 10:07 AM
To: php-general@lists.php.net
Subject: [PHP] Last Sunday in September?

Hi,

I'm building a program and I need to find the last Sunday in September
for
every year because the following Monday is the start of a new year for
us.
So 2006 ends on September 24th 2006 and the new year (2007) starts on
September 25th 2006.  I was thinking that using the strtotime() would
get me
this information possibly?  Is there an easy way to get this
information?

Pseudo code:

If ((date > last Sunday in September this year) &&
(date < Jan 1 of next year)) {
year++
}

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Last Sunday in September?

2006-02-17 Thread tg-php
There's going to be 'tighter' and more efficient ways to do this.. probably 
some using strtotime().  I have an irrational distrust of the results from 
strtotime() though, so I use it sparingly.

Here's a simple solution though:



There's going to be a dozen ways to skin this one, just showing one way.

-TG

= = = Original message = = =

Hi,

I'm building a program and I need to find the last Sunday in September for
every year because the following Monday is the start of a new year for us.
So 2006 ends on September 24th 2006 and the new year (2007) starts on
September 25th 2006.  I was thinking that using the strtotime() would get me
this information possibly?  Is there an easy way to get this information?

Pseudo code:

If ((date > last Sunday in September this year) &&
(date < Jan 1 of next year)) 
year++


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php