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 8736447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:18:17+00:00 2026-06-13T10:18:17+00:00

Suppose that I have code as below: $(‘#dateNaissance’).datepicker({ onSelect:function(date){ var today=new Date(); console.log(today.getTime()); console.log(new

  • 0

Suppose that I have code as below:

$('#dateNaissance').datepicker({
        onSelect:function(date){
        var today=new Date();
        console.log(today.getTime());
        console.log(new Date(date));
        console.log(DateDiff(today,new Date(date)));

        $('#txtage').val(DateDiff(today,new Date(date)));


        }        


    });


    function DateDiff(date1,date2) {
        return (date1.getTime() - date2.getTime());
    }
    <tr>
        <td>Date de naissance :</td>
        <td><input type="text" name="txtdob" class="validate[required] text-input datepicker TextInput"  id="dateNaissance"/></td>
        <td>Age :<br /><input type="text" name="txtage" class="validate[required] TextInput" id="txtage"/></td>
    </tr>

I need:

when the user select date from date picker,it will calculate automatic with date now to get the result in <td>Age :<br /><input type="text" name="txtage" class="validate[required] TextInput" id="txtage"/></td> ex:23 year.

Problem

When I do follow as the code above,it will have the result as the number in <td>Age :<br /><input type="text" name="txtage" class="validate[required] TextInput" id="txtage"/></td> ex:1954172067.I do not know how to fix this.Anyone help me please,thanks.

  • 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-13T10:18:18+00:00Added an answer on June 13, 2026 at 10:18 am

    I hope the code below can help you:

     $('#dateNaissance').datepicker({
            onSelect:function(date){
            var today=new Date();
            console.log(today.getTime());
            console.log(new Date(date));
            console.log(DateDiff(today,new Date(date)));        
            $('#txtage').val(DateDiff(today,new Date(date)));       
            }        
    });
        function DateDiff(date1,date2) {
            var val = (date1.getTime() - date2.getTime());
            var days = Math.round(val /1000 / 60 / 60 / 24);
            var years = Math.round(days /365);
            return years;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

suppose that,we have following code auto_ptr<T> source() { return auto_ptr<T>( new T(1) ); }
Suppose that I have below code: <?php $html = ' <form id=formA> <!-- Form
Suppose I have this database table (some sample code below) that stores the relationship
Suppose that I have the code php as below: <?php include(connectdb.php); $check1 = ;
Suppose that I have the PHP code as below: class modual { public $glo;
Suppose that I have the PHP code as below: <html> <head> <title>Convert HTML to
As a toy example, suppose that we have a function called 'my_func' (the code
Suppose I have the code below that needs to throw an exception from withing
Suppose I have code that maintains a parent/children structure. In such a structure I
I have this code that suppose to place the marker by the latlng public

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.