Home Web Front-end JS Tutorial jquery js obtains the specific code of time difference and time format_jquery

jquery js obtains the specific code of time difference and time format_jquery

May 16, 2016 pm 05:32 PM
Time difference Time format

Retrieve

Copy code The code is as follows:

GetDateDiff(start, end, "day")
/*
* Get the time difference, the time format is year-month-day hour:minute:second or year/month/day hour:minute:second
* Among them, year, month and day are in full format, for example : 2010-10-12 01:00:00
* The return precision is: seconds, minutes, hours, days
*/
function GetDateDiff(startTime, endTime, diffType) {
//will The time format of xxxx-xx-xx is converted to the format of xxxx/xx/xx
startTime = startTime.replace(/-/g, "/");
endTime = endTime.replace(/-/g , "/");
//Convert calculation interval characters to lowercase
diffType = diffType.toLowerCase();
var sTime = new Date(startTime); //Start time
var eTime = new Date(endTime); //End time
//Number as divisor
var divNum = 1;
switch (diffType) {
case "second":
divNum = 1000;
break;
case "minute":
divNum = 1000 * 60; break;
case "day":
divNum = 1000 * 3600 * 24;
break;
default:
break;
}
return parseInt((eTime.getTime () - sTime.getTime()) / parseInt(divNum)); //17jquery.com
}

Statement of this Website
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

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to set the 24-hour time format on Huawei mobile phones. Learn in seconds: Set the 24-hour time on Huawei Honor mobile phones. How to set the 24-hour time format on Huawei mobile phones. Learn in seconds: Set the 24-hour time on Huawei Honor mobile phones. Mar 26, 2024 am 11:11 AM

Huawei Honor mobile phones provide you with two timing methods, which are divided into 12 hours and 24 hours. Generally, mobile phones default to the 12-hour format, but many friends are more accustomed to using the 24-hour format, which allows us to understand morning and afternoon more clearly. Let’s take a look at the specific setting tutorial! How to enable the 24-hour clock on Huawei Honor mobile phones: 1. Open the phone settings and click [System and Updates]. 2. Click [Date and Time] on the system update page. 3. Turn on the switch on the right side of [24-hour format]. This is all the content of the entire article. I hope more novice friends can get help. After reading this article on how to adjust the 24-hour time format on Huawei mobile phones, "Understand in seconds: Setting the 24-hour time on Huawei Honor mobile phones" is still not quite right.

Calculate the number of days difference between dates in php Calculate the number of days difference between dates in php Apr 09, 2024 pm 01:06 PM

How to calculate the number of days between dates in PHP: Use the date_diff() function to obtain the DateInterval object. Extract the days property in the diff array from the DateInterval object. This property contains the number of days between two dates.

Convert Unix timestamp to time format using time.Unix function and set time zone Convert Unix timestamp to time format using time.Unix function and set time zone Jul 25, 2023 pm 12:28 PM

Title: Use the time.Unix function to convert Unix timestamps to time format and set the time zone. In the Go language, we often need to convert Unix timestamps into a readable time format, and often need to consider setting the time zone. This article will introduce how to use the Unix function in the time package to accomplish this task, and demonstrate how to set the time zone. First, we need to understand what Unix timestamp means. A Unix timestamp is an integer in seconds representing the time since January 1, 1970

Sharing the steps to modify the time format in Oracle Sharing the steps to modify the time format in Oracle Mar 06, 2024 pm 04:18 PM

Title: Step sharing and specific code examples for modifying the time format in Oracle database. In Oracle database, the display of time format is crucial for data analysis and report output. The correct time format can make the data more intuitive and clear, and improve the efficiency of data processing. In practical applications, sometimes we need to modify the time field in the database to a specific format, which requires time format conversion. Next, this article will share the specific steps to modify the time format in the Oracle database, and provide code examples to

When will Microsoft release the win10 time format? When will Microsoft release the win10 time format? Jul 21, 2023 pm 11:25 PM

There are some netizens who are new to computers and operating systems and do not know the corresponding Microsoft operating system. They are interested in the release date and history of the win10 operating system, and want to know when Microsoft will release the win10 system software. In response to this problem, let me explain to you the time when Microsoft released win10. When was win10 released? Introduction to win10 announced on July 29, 2015: 1. The Windows 10 operating system has greatly improved convenience and security. 2. In addition to integrating new technology applications such as cloud servers, smart mobile devices, and of course human-computer interaction, In addition, hardware equipment such as solid-state drives, biometrics, and high-pixel displays have also been improved, improved, and applied.

How does Oracle modify the time format? How does Oracle modify the time format? Mar 06, 2024 pm 03:00 PM

Modification of the time format in Oracle database is very common in actual development. This article will introduce how to modify the time format in Oracle database and provide specific code examples. In Oracle database, there are two main time data types: DATE and TIMESTAMP. The DATE type stores date and time, while the TIMESTAMP type can store higher-precision time information. When modifying the time format, you can use the TO_CHAR function. Next we

How to use the time function in Go language to calculate the time difference and format the output? How to use the time function in Go language to calculate the time difference and format the output? Aug 01, 2023 am 08:01 AM

How to use the time function in Go language to calculate the time difference and format the output? The Go language provides a powerful set of time functions to manipulate and calculate time. In many applications, we often need to calculate the time difference and output it in a specific format. This article will introduce how to use the time function in the Go language to calculate the time difference and format the output. First, we need to import the time package: import "time" Next, we can use the time.Now() function to get the current

How to use date functions to process time formats How to use date functions to process time formats Jun 16, 2023 am 08:39 AM

The date function is a very practical tool in Excel, which can help us easily process various time formats. Whether you need to convert a date to another format, calculate the time between dates, or sort dates for archiving, date functions can help you solve your problem. In this article, we will introduce some commonly used date functions and explain in detail how to use these functions to process time formats. 1. Basic knowledge of date functions In Excel, dates and times are stored in numeric form. Each date corresponds to Exc

See all articles