Results 1 to 3 of 3

Thread: Script that calculates age from a given date

  1. #1
    Join Date
    Dec 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Script that calculates age from a given date

    I am trying to find a script, or help writing a script that displays the age of a business for a yearly anniversary.

    For instance, if they opened in 1978, I want to display a statement that says "Celebrating our 32 year anniversary."

    It seems like this should be simple, but I am struggling! Any ideas?


  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    How do you want to store the information? Is this a single business or do you want many listings?

    It's basic math once it's stored as a variable.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Dec 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    It's a single business. I was trying to find a way to display it so that the number would turn over on the exact day, but I must be messing up the math...my script isn't displaying anymore.


    var opendate =new Date(2000, 8, 16)
    today=new Date()
    var one_day=((((Age/1000)/60)/60)/24)/365.25)

    //Calculate difference between two dates
    document.write("Celebrating our " + (Math.ceil((today.getTime()-opendate.getTime())/(one_day))+
    " anniversary!"))

    </script>

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
  •