M1L4D
M1L4D

Reputation: 11

javascript - get the date value

I have a problem. I use a date picker in my html page which I want to get value of input date using jquery. I used this :

var birthday_date = $("#birthday_date").val();

but it's not working. I checked the inspect code then realise when I used date picker, the input tag (which used for date) becomes to this :

<input id="textbox1" 
   name="birthday_date" 
   data-targetselector="#textbox1" 
   class="form-control" 
   data-mddatetimepicker="true" 
   placeholder="year/month/day" 
   data-placement="top" 
   maxlength="10" 
   data-mdpdatetimepicker="" 
   data-trigger="click" 
   data-enabletimepicker="false" 
   data-mdformat="yyyy/MM/dd" 
   data-mdpdatetimepickerselecteddatetime="
       {"Year":2011,"Month":8,"Day":2,"Hour":9,"Minute":13,"Second":14}" 
   data-original-title="" 
   title="" 
   data-mdpdatetimepickershowing="true" 
   aria-describedby="popover30621" 
   type="text">

the value of the date is this part:

 mdpdatetimepickerselecteddatetime="{"Year":2011,"Month":8,"Day":2,"Hour":9,"Minute":13,"Second":14}"

the time is not matter, I just wanna date , google gave me nothing and I have no idea how can I get the value like this, any help? or something to help me?

Upvotes: 0

Views: 129

Answers (1)

Azeez Kallayi
Azeez Kallayi

Reputation: 2642

If you are using datepicker, you can access the value like this:

var date = $('#textbox1').datepicker('getDate');

Upvotes: 1

Related Questions