Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何以“2014年1月”格式获取从日期算起的月份数?_Php_Jquery_Date_Format - Fatal编程技术网

Php 如何以“2014年1月”格式获取从日期算起的月份数?

Php 如何以“2014年1月”格式获取从日期算起的月份数?,php,jquery,date,format,Php,Jquery,Date,Format,实际上,我正在使用jquery datepicker并以月-年格式获取月份? 如何用PHP或JAVASCRIPT从这种格式中获取月数 js代码: $("#date1_live").datepicker({ changeMonth: true, changeYear: true, showAnim:'slideDown', dateFormat:'M

实际上,我正在使用jquery datepicker并以月-年格式获取月份? 如何用PHP或JAVASCRIPT从这种格式中获取月数

js代码:

  $("#date1_live").datepicker({
            changeMonth: true,
            changeYear: true,
                        showAnim:'slideDown',
                        dateFormat:'M yy'
        });      
html文本字段:

<input type="text" name="reportMonth" id="date1_live" required Placeholder="Select Start Date" >

请查看以下文档

解析和显示日期的格式。有关 可能的格式请参见formatDate函数。 代码示例: 使用指定的dateFormat选项初始化日期选择器:


使用php尝试如下

$month = 'JAN-2014';
echo date('m', strtotime($month));
试试这个

 alert($("#datepicker").datepicker({ dateFormat: "mm-yy" }).val());


请提供一些示例,说明您得到了什么以及您想要实现什么。jquery datepicker文本字段以月-年格式输出我的日期。e、 g当我从7月选择任何日期时,它返回我2014年7月。所以,我需要从这个日期算起的月份数!我该怎么做呢?分享一些你已经尝试过的相关代码,如果你能分享JSFIDLE会更好,这样我们可以帮助你。如果使用正确,jQuery的datepicker将返回一个日期对象,所以你做得不对。如果这个答案对你有用,请投票并选择这个作为答案
 alert($("#datepicker").datepicker({ dateFormat: "mm-yy" }).val());
         {
            changeMonth: true,
            changeYear: true,
            showAnim:'slideDown',
            dateFormat:"mm-yy"
       }