search
HomeWeb Front-endJS TutorialJavascript date processing time zone issue_time and date

Copy code The code is as follows:

//dateObj is a date object, days represents how much to add to this date Days, for example 4, 5 (days)
function dateAdd(dateObj,days){
var tempDate = dateObj.valueOf();
tempDate = tempDate days * 24 * 60 * 60 * 1000;
tempDate = new Date(tempDate);
return tempDate;
}

//Then use, create a date object
var dateValue = document.getElementById("XXYY"). value.split("-");
var custArvDateTwoValue = new Date(dateValue[0],dateValue[1]-1,dateValue[2]);
//Call dateAdd and add two days
custArvDateTwoValue = dateAdd(custArvDateTwoValue,2);
var year = custArvDateTwoValue.getFullYear();
var month = custArvDateTwoValue.getMonth() 1;
var days = custArvDateTwoValue.getDate();
month = month days = days document.getElementById("XX").value = year "-" month "-" days;

I found during testing that when the value of document.getElementById("XXYY").value is 2009-10-31
the returned value is actually 2009- 11-01

Other situations are correct, for example, if you enter 2009-10-01, it will return 2009-10-03
I also tried today and the last day of each month next year, only 2009 -10-31 has a problem (I tried many times, only this time has a problem, the difficulty is 32 days in this month)

When I try 2009-10-31, the returned is 2009-11-01 too Correct

In the end, it was found that it was a time zone problem, so if you find this kind of problem in the future, you can check to see if the time zone does not correspond.
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Ubuntu17.10顶栏怎么显示日期与计秒?Ubuntu17.10顶栏怎么显示日期与计秒?Jan 08, 2024 am 10:41 AM

Ubuntu17.10顶栏默认只有当前的时间,没有日期,想要显示日期,该怎么办呢?下面我们就来看看详细的教程。1、在启动器打开终端,或者按[Ctrl+Alt+T]2、终端输入:sudoaptinstallgnome-tweak-tool3、安装完成之后,打开tweak工具4、点击TopBar5、Date就是日期,seconds就是秒数6、设置好之后,顶栏的时间上就显示了日期,以及秒

如何使用Python中的时间和日期模块如何使用Python中的时间和日期模块Oct 16, 2023 am 08:11 AM

如何使用Python中的时间和日期模块导言:在编程中,处理时间和日期是非常常见的任务。Python提供了强大的时间和日期模块,使得处理时间和日期的操作变得更加简单和方便。本文将介绍Python中的时间和日期模块,并提供具体的代码示例,帮助读者更好地理解和应用它们。一、引入时间和日期模块Python内置的时间和日期模块是datetime模块,我们需要先引入该模

超全!Python获取某一日期是“星期几”的六种方法!超全!Python获取某一日期是“星期几”的六种方法!Apr 19, 2023 am 09:28 AM

在Python进行数据分析时,按照日期进行分组汇总也是被需要的,比如会找到销量的周期性规律。那么在用Python进行数据统计之前,就需要额外增加一步:从指定的日期当中获取星期几。比如2022年2月22日,还正好是正月廿二星期二,于是乎这一天登记结婚的人特别多。本文就以2022-02-22为例,演示Python获取指定日期是“星期几”的6种方法!weekday()datetime模块是一个Python内置库,无需再进行pip安装,它除了可以显示日期和时间之外,还可以进行日期和时间的运算以及格式化。

PHP数据过滤:处理日期和时间输入PHP数据过滤:处理日期和时间输入Jul 28, 2023 pm 07:41 PM

PHP数据过滤:处理日期和时间输入概述:在开发网页应用程序时,经常需要处理用户输入的日期和时间数据。由于用户的输入可能存在各种格式和错误,因此必须进行有效的数据过滤和验证,以确保数据的准确性和安全性。本文将介绍如何使用PHP来处理日期和时间输入,并提供相应的代码示例。过滤和验证原则:在处理日期和时间输入之前,首先需要确定相应的过滤和验证原则。以下是一些常见的

如何使用Python生成两个日期之间的k个随机日期?如何使用Python生成两个日期之间的k个随机日期?Sep 09, 2023 pm 08:17 PM

生成随机数据在数据科学领域非常重要。从构建神经网络预测、股市数据等来看,通常都会将日期作为参数之一。我们可能需要在两个日期之间生成随机数以进行统计分析。本文将展示如何生成两个给定日期之间的k个随机日期使用随机和日期时间模块日期时间是Python内置的处理时间的库。另一方面,随机模块有助于生成随机数。因此,我们可以结合随机和日期时间模块来生成两个日期之间的随机日期。语法random.randint(start,end,k)这里的random指的是Python随机库。randint方法采用三个重要的

MySQL中如何使用DATEDIFF函数计算两个日期之间的天数差MySQL中如何使用DATEDIFF函数计算两个日期之间的天数差Jul 13, 2023 am 08:00 AM

MySQL中如何使用DATEDIFF函数计算两个日期之间的天数差在MySQL数据库中,DATEDIFF函数可以方便地计算两个日期之间的天数差。这个函数接受两个日期作为参数,并返回它们之间的天数差。使用DATEDIFF函数的语法如下:DATEDIFF(date1,date2)其中,date1和date2是两个要比较的日期参数。这两个参数可以是日期类型的列名、

PHP日期处理技巧:快速确定某个日期的星期几PHP日期处理技巧:快速确定某个日期的星期几Mar 20, 2024 am 08:15 AM

PHP作为一种广泛应用于Web开发领域的编程语言,提供了丰富的日期处理函数,可以方便地对日期进行操作和计算。其中,快速确定某个日期是星期几是一个常见且实用的需求。本文将介绍如何利用PHP中的函数来快速确定某个日期的星期几,并提供具体的代码示例。PHP中日期处理函数简介PHP中关于日期处理的主要函数有date()、strtotime()、str

如何使用MySQL中的UNIX_TIMESTAMP函数将日期转换为时间戳如何使用MySQL中的UNIX_TIMESTAMP函数将日期转换为时间戳Jul 13, 2023 pm 12:00 PM

如何使用MySQL中的UNIX_TIMESTAMP函数将日期转换为时间戳时间戳是一个表示日期和时间的数字,它通常用于在计算机系统中存储和处理日期和时间。在MySQL中,可以使用UNIX_TIMESTAMP函数将日期转换为时间戳。本文将介绍如何使用UNIX_TIMESTAMP函数来实现这一转换。首先,我们需要了解UNIX_TIMESTAMP函数的用法。UNIX

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment