Let's say I have $easter = 0415. ( equivalent to date("md") for April 15th)
There are christian celebrations that take place some specific number of days beofre & after Easter. Now how di I deduce, for example, the date() of Mardi-Gras ? (here it happens 47 days before Easter).
Is there a way to make date on "md"-47 ? So that it would be 0228 in this case. (if I'm not mistaken)
Shin Ma - I just looked up some info on the php date and time functions at http://www.php.net/manual/en/ref.datetime.php . So the code below is untested. However, I think the idea is to use unix timestamps (seconds since unix epoch) for calculations.
$easter = mktime (0,0,0,04,15,2001);
$fourtySevenDays = 60*60*24*47; // fourty seven days as seconds
$madiGras = $easter - $fourtySevenDays;
// echo $madiGras as a string formated into d M Y
echo date("d M Y", $madiGras);
Oh, that's exactly what I thought I'd do, but I didn't know how to do it, thanks a lot :D
Just as a side note one can achieve this calculation a lot easier, and although freakysid's idea works it can be done faster and easier.
print date("md", mktime(0,0,0,4,15 - 47,2001));