SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    will code HTML for food Michel V's Avatar
    Join Date
    Sep 2000
    Location
    Corsica
    Posts
    552
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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)
    [blogger: zengun] [blogware contributor: wordpress]

  2. #2
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.
    PHP Code:
    $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); 

  3. #3
    will code HTML for food Michel V's Avatar
    Join Date
    Sep 2000
    Location
    Corsica
    Posts
    552
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh, that's exactly what I thought I'd do, but I didn't know how to do it, thanks a lot
    [blogger: zengun] [blogware contributor: wordpress]

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

    PHP Code:
    print date("md"mktime(0,0,0,4,15 47,2001)); 
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •