code that shows whose birthday it is today

Discussion in 'JavaScript' started by patr1c1a, Nov 14, 2006.

  1. #1
    I'm looking for some javascript code that shows whose birthday is every day.
    Something that tells me: "today is [xxx's] birthday"
    where I can set a person's name for each day/month of the year.
    I couldn't find anything like that, other than full calendars where the user has to pick the day or something. I only need it to tell on each day whose birthday is.
     
    patr1c1a, Nov 14, 2006 IP
  2. lucianp

    lucianp Peon

    Messages:
    25
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    That's because nobody has thinking for something so simple...
     
    lucianp, Nov 14, 2006 IP
  3. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #3
    Try this. Just add the birthdays like in the example.

    
    <div id="birthday">Today's birthday: </div>
    
    <script type="text/javascript">
    <!--
    var birthdays = new Array();
    
    birthdays['2006-11-14'] = 'Someone';
    birthdays['2006-11-15'] = 'Someone else';
    birthdays['2006-11-16'] = 'Who knows';
    
    
    var date = new Date();
    var day = date.getDate();
    var month = date.getMonth()+1;
    var year = date.getFullYear();
    var birthday = birthdays[year +'-'+ month +'-'+ day] ? birthdays[year +'-'+ month +'-'+ day] : 'None';
    document.getElementById('birthday').innerHTML += birthday;
    
    //-->
    </script>
    
    
    Code (javascript):
     
    nico_swd, Nov 14, 2006 IP