【问题标题】:Why is datepicker ui one week behind php date("W")为什么 datepicker ui 比 php date("W") 晚一周
【发布时间】:2016-01-30 00:42:18
【问题描述】:

我正在使用 php 和 datepicker 来处理需要日期中的周数的应用程序。我刚刚注意到 datepicker 比 php date("W") 晚一周。我有一个Fiddle 显示这个问题。有没有办法纠正这个问题?感谢您提供任何见解。

JS:

 <script>
    $(document).ready(function () {
        $( ".datepicker" ).datepicker({
           showWeek: true,
           dateFormat: 'yy-mm-dd' 
         });
    });
 </script>

PHP:

<?php echo 'Current week ' .date("W");?>

HTML:

<input name="date_task[]" class="datepicker" type="text"  />

【问题讨论】:

    标签: php jquery jquery-ui datepicker


    【解决方案1】:

    我能够通过将一周的第一天更改为星期一来解决此问题。

     <script>
       $(document).ready(function () {
         $( ".datepicker" ).datepicker({
                  showWeek: true,
                  dateFormat: 'yy-mm-dd', 
                  firstDay: 1
             });
         });
     </script>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-07
      • 1970-01-01
      • 1970-01-01
      • 2019-08-31
      • 2013-03-11
      • 1970-01-01
      • 2013-07-23
      • 2020-03-05
      相关资源
      最近更新 更多