RE: [PEAR] Calendar_Day is Sunday?

From: Date: Thu, 12 Feb 2004 16:35:22 +0000
Subject: RE: [PEAR] Calendar_Day is Sunday?
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-10655@lists.php.net to get a copy of this message
On Thu, 12 Feb 2004 15:51:59 -0000, Mike Carter wrote: >> From: Stefan Neufeind [mailto:Neufeind@speedpartner.de] >> On 12 Feb 2004 at 15:39, Michael Wallner wrote: >>> is there a neat short way, I don't know of, >>> to determine if a Calendar_Day is a Sunday? >> >> Make timestamp from your date using mktime() and then feed that >> into getdate. Will give you also "wday" (weekday) where 0 >> represents a Sunday. > > What if the timestamp is before 1970 though (such as a date of > birth)? This will just go all bad due to random definition of what > happens before 1970 with unix timestamps. Is it not possible to use > something from the PEAR::Date class to avoid this? > > - Mike C you can use the PEAR::Date engine, like this: [ all the timestamps will be ISO-8601 timestamps (i.e. YYYY-MM-DD HH:MM:SS) ] ========= define('CALENDAR_ENGINE', 'PearDate'); require_once 'Calendar/Day.php'; $day = new Calendar_Day(2004, 02, 12); $dayoftheweek = $day->cE->getDayOfWeek($y, $m, $d); ========= Please note that ->cE-> is private, though. Alternatively, you can do: =============== $date = $day->thisDay('array'); $dayoftheweek = Date_Calc::dayOfWeek($date['day'], $date['month'], $date['year']); =============== HTH Lorenzo

« previous php.pear.general (#10655) next »