troubleshooting Question

How to get age from date of birth

Avatar of Abraham Augustus Nortey
Abraham Augustus Nortey asked on
JavaScriptHTMLPHPSQL
5 Comments1 Solution53 ViewsLast Modified:
I have a profile page with date of birth as an option and i wish to convert the date of birth to a number and assign it to Age column. Below is the code for the date of bitth  and the code for age

Screenshot--282-.png
<div class="form-group">
                 <label for="date_of_birth">Date of birth</label>
                
                <div class="input-group date form_date col-md-5" data-date="" data-date-format="dd MM yyyy" data-link-field="dtp_input2" data-link-format="yyyy-mm-dd">
                    <input type="text" class="form-control" value="<?php if(isset($date_of_birth)) echo $date_of_birth; ?>" size="16" readonly>
                    <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
					<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
             </div>
				<input type="hidden" id="dtp_input2" name="date_of_birth" value="<?php if(isset($date_of_birth)) echo $date_of_birth; ?>" /><br/>
            </div>
	
</div>

<script type="text/javascript" src="jquery/jquery-1.8.3.min.js" charset="UTF-8"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/bootstrap-datetimepicker.js" charset="UTF-8"></script>

<script type="text/javascript">
    $('.form_datetime').datetimepicker({
        //language:  'fr',
        weekStart: 1,
        todayBtn:  1,
		autoclose: 1,
		todayHighlight: 1,
		startView: 2,
		forceParse: 0,
        showMeridian: 1
    });
	$('.form_date').datetimepicker({
        language:  'fr',
        weekStart: 1,
        todayBtn:  1,
		autoclose: 1,
		todayHighlight: 1,
		startView: 2,
		minView: 2,
		forceParse: 0
    });
	$('.form_time').datetimepicker({
        language:  'fr',
        weekStart: 1,
        todayBtn:  1,
		autoclose: 1,
		todayHighlight: 1,
		startView: 1,
		minView: 0,
		maxView: 1,
		forceParse: 0
    });
</script>



	<div class="form-group">
                        <label for="ageField">Age</label>
                        <input type="text" name="age" value="<?php if(isset($age)) echo $age; ?>" class="form-control" id="ageField">
                    </div>
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros