Actually, i am using jquery datepicker and getting month in "MONTH-YEAR" format? how i can get month number form this format in PHP or JAVASCRIPT?
js code:
$("#date1_live").datepicker({
changeMonth: true,
changeYear: true,
showAnim:'slideDown',
dateFormat:'M yy'
});
html text field:
<input type="text" name="reportMonth" id="date1_live" required Placeholder="Select Start Date" >
using php try like this
$month = 'JAN-2014';
echo date('m', strtotime($month));
Please take a look at the following documentation.
The format for parsed and displayed dates. For a full list of the possible formats see the formatDate function. Code examples: Initialize the datepicker with the dateFormat option specified:
$( ".selector" ).datepicker({ dateFormat: "yy-mm-dd" });
try this,
alert($("#datepicker").datepicker({ dateFormat: "mm-yy" }).val());
or Demo
{
changeMonth: true,
changeYear: true,
showAnim:'slideDown',
dateFormat:"mm-yy"
}