1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

I need help with simple date script

Discussion in 'PHP' started by Grendor, Apr 16, 2005.

  1. #1
    According to what date it is, it has to generate horoscope sign, season of the year(winter,spring,etc). I know this in javascript but in php I'm a rookie.
    For example if the current date is between 22.5-21.6 horoscope would be gemini and for the season would be summer(of course, the season would have to have different range of date).

    I just need a few lines of code to show me how should I approuch this, the rest would be easy.
     
    Grendor, Apr 16, 2005 IP
  2. king_cobra

    king_cobra Peon

    Messages:
    373
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #2
    post the javascript and i will convert that to php for u.
     
    king_cobra, Apr 16, 2005 IP
  3. Grendor

    Grendor Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    This works but with mistakes reported, I think the include part is in the wrong place. Could you please fix it?

    <html>
    <head>
    <title>Time></title>
    </head>

    <body>
    <?php

    include('time.php');
    echo getHoroscopeSign();
    echo getSeason();


    function getHoroscopeSign($time = null)
    {
    if($time == null) $time = time();
    $h = array(20,19,21,20,21,22,23,23,23,23,22,22); //Start days of months 0-11
    $s = array('Aquarius','Pisces','Aries','Taurus','Gemini','Cancer','Leo','Virgo','Li bra','Scorpio','Sagittarius','Capricorn');

    $month = date('n',$time);
    $date = date('d',$time);

    if($date < $h[$month-1])
    {
    return $s[$month-2 == -1 ? 11 : $month-2]; //Previous sign
    }
    else
    {
    return $s[$month-1]; //Current Sign
    }
    }



    echo getHoroscopeSign() . '<br />';

    function getSeason($time = null)
    {
    if($time == null) $time = time();
    $s = array('Spring','Summer','Autumn','Winter');
    $month = date('n',$time);
    if(date('d',$time) >= 21) $month++;
    $season = floor($month / 3);
    $season--;
    return $s[$season < 0 ? 3 : $season];
    }


    ?>

    </body>
    </html>
     
    Grendor, Apr 17, 2005 IP