Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7974521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:23:56+00:00 2026-06-04T08:23:56+00:00

Here is my code, as taken from here: Calculate age in JavaScript var today

  • 0

Here is my code, as taken from here: Calculate age in JavaScript

        var today = new Date();
        birthday_val = $(".datepicker").val().split('/'); // input value
        birthday = new Date(birthday_val[2],birthday_val[1],birthday_val[0]); // birthday date object
        var age = today.getFullYear() - birthday.getFullYear();
        var m = today.getMonth() - birthday.getMonth();
        var d = today.getDay() - birthday.getDay();
        if (m < 0 || (m === 0 && today.getDate() < birthday.getDate()) ) {
            age--;
        }

It calculates it right except for the day – doesnt take this into account and I cant figure out why. Any takers?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T08:23:57+00:00Added an answer on June 4, 2026 at 8:23 am

    Edit: This isn’t the correct answer, despite being marked so by the OP.


    You’re using the incorrect method to retrieve the day of the month.

    Date.getDay returns the day of the week

    Date.getDate returns the day of the month

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using this code taken from here : import smtplib def prompt(prompt): return
Is this possible to do the following in ExpressionEngine: (code taken from here )
How should I understand $(select option:selected) in the following code ? (taken from here
Here is a code taken from http://www.angelfire.com/tx4/cus/shapes/haskell98.html . It compiles and executes correctly in
Here is code from MSDN . I don't understand why the work isn't just
There's this code from here ub4 additive(char *key, ub4 len, ub4 prime) { ub4
Here's my current code , and here's my current output: This program will calculate
Here's my (code golf) challenge: Take two arrays of bytes and determine if the
Here's a piece of code that takes most time in my program, according to
you can view full source code here dpaste.com/hold/167199 Error: delete() takes exactly 2 arguments

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.