• <legend id='0tnic'><style id='0tnic'><dir id='0tnic'><q id='0tnic'></q></dir></style></legend>
  • <i id='0tnic'><tr id='0tnic'><dt id='0tnic'><q id='0tnic'><span id='0tnic'><b id='0tnic'><form id='0tnic'><ins id='0tnic'></ins><ul id='0tnic'></ul><sub id='0tnic'></sub></form><legend id='0tnic'></legend><bdo id='0tnic'><pre id='0tnic'><center id='0tnic'></center></pre></bdo></b><th id='0tnic'></th></span></q></dt></tr></i><div id='0tnic'><tfoot id='0tnic'></tfoot><dl id='0tnic'><fieldset id='0tnic'></fieldset></dl></div>
    • <bdo id='0tnic'></bdo><ul id='0tnic'></ul>
    <tfoot id='0tnic'></tfoot>

        <small id='0tnic'></small><noframes id='0tnic'>

        JavaScript Date 对象的月份索引从 0 开始

        JavaScript Date Object#39;s month index begins with 0(JavaScript Date 对象的月份索引从 0 开始)
      1. <i id='w8Nzz'><tr id='w8Nzz'><dt id='w8Nzz'><q id='w8Nzz'><span id='w8Nzz'><b id='w8Nzz'><form id='w8Nzz'><ins id='w8Nzz'></ins><ul id='w8Nzz'></ul><sub id='w8Nzz'></sub></form><legend id='w8Nzz'></legend><bdo id='w8Nzz'><pre id='w8Nzz'><center id='w8Nzz'></center></pre></bdo></b><th id='w8Nzz'></th></span></q></dt></tr></i><div id='w8Nzz'><tfoot id='w8Nzz'></tfoot><dl id='w8Nzz'><fieldset id='w8Nzz'></fieldset></dl></div>

          <tbody id='w8Nzz'></tbody>

          1. <small id='w8Nzz'></small><noframes id='w8Nzz'>

              • <legend id='w8Nzz'><style id='w8Nzz'><dir id='w8Nzz'><q id='w8Nzz'></q></dir></style></legend>
                • <bdo id='w8Nzz'></bdo><ul id='w8Nzz'></ul>
                  <tfoot id='w8Nzz'></tfoot>

                • 本文介绍了JavaScript Date 对象的月份索引从 0 开始的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我的目标是以有效的方式将 MySQL 中的时间戳转换为 JavaScript Date 对象.这是我当前的片段,它将 MySQL 时间戳转换为 PHP 中的格式化日期:

                  My goal is to convert a timestamp from MySQL into a JavaScript Date object in an efficient manner. Here is my current snippet that converts the MySQL timestamp into a formatted date in PHP:

                  <?php
                  // formats timestamp into following format: 2009, 7, 30
                  $date =  date("Y, n, j", strtotime($row["date"]));
                  ?>
                  

                  然后我将这个 $date 值用于使用需要 JavaScript Date 对象的 Google 图表 API 的图表:

                  I am then using this $date value for a chart using Google's charting API which requires JavaScript Date object:

                  data.setValue(<?=$count;?>, 0, new Date(<?=$date;?>));
                  

                  问题在于 JavaScript Date 对象以 0 开始月份索引,因此输出总是提前 1 个月.处理这个问题最有效的方法是什么?

                  The problem is that the JavaScript Date object begins the month index with 0 so the output is always 1 month in advance. What is the most efficient way in dealing with this issue?

                  提前致谢!

                  推荐答案

                  您可以为 Date 构造函数提供一个 mm/dd/yyyy 或 yyyy/mm/dd 格式的日期,它会转换它:

                  You can feed the Date constructor a date in mm/dd/yyyy or yyyy/mm/dd format and it will convert it:

                  >>> new Date('7/30/2009');
                  Thu Jul 30 2009 00:00:00 GMT-0700 (Pacific Daylight Time)
                  >>> new Date('2009/7/30');
                  Thu Jul 30 2009 00:00:00 GMT-0700 (Pacific Daylight Time)
                  

                  这篇关于JavaScript Date 对象的月份索引从 0 开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                • <legend id='DgyRZ'><style id='DgyRZ'><dir id='DgyRZ'><q id='DgyRZ'></q></dir></style></legend>
                    <bdo id='DgyRZ'></bdo><ul id='DgyRZ'></ul>
                      <tbody id='DgyRZ'></tbody>

                      <small id='DgyRZ'></small><noframes id='DgyRZ'>

                        1. <tfoot id='DgyRZ'></tfoot>
                        2. <i id='DgyRZ'><tr id='DgyRZ'><dt id='DgyRZ'><q id='DgyRZ'><span id='DgyRZ'><b id='DgyRZ'><form id='DgyRZ'><ins id='DgyRZ'></ins><ul id='DgyRZ'></ul><sub id='DgyRZ'></sub></form><legend id='DgyRZ'></legend><bdo id='DgyRZ'><pre id='DgyRZ'><center id='DgyRZ'></center></pre></bdo></b><th id='DgyRZ'></th></span></q></dt></tr></i><div id='DgyRZ'><tfoot id='DgyRZ'></tfoot><dl id='DgyRZ'><fieldset id='DgyRZ'></fieldset></dl></div>