Home Web Front-end JS Tutorial Web page date formatting plug-in based on jquery_jquery

Web page date formatting plug-in based on jquery_jquery

May 16, 2016 pm 05:59 PM
date formatting

复制代码 代码如下:

(function ($) {
var FormatDateTime = function FormatDateTime() { };
$.FormatDateTime = function (obj, IsMi) {
var correcttime1 = eval('( new ' obj.replace(new RegExp("/", "gm"), "") ')');
var myDate = correcttime1;
var year = myDate.getFullYear();
var month = ("0" (myDate.getMonth() 1)).slice(-2);
var day = ("0" myDate.getDate()).slice(-2);
var h = ("0" myDate.getHours()).slice(-2);
var m = ("0" myDate.getMinutes()).slice(-2);
var s = ("0" myDate.getSeconds()).slice(-2);
var mi = ("00" myDate.getMilliseconds()).slice(-3);
if (IsMi == true) {
return year "-" month "-" day " " h ":" m ":" s;
}
else {
return year "-" month "-" day " " h ":" m ":" s " " mi;
}

}
})(jQuery);


使用方法:
复制代码 代码如下:

$.FormatDateTime(item.ControlEndTime, false)

//item.ControlEndTime:后台返回的日期
//false:布尔型,是否返回毫秒
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 deal with date formatting errors in PHP language development? How to deal with date formatting errors in PHP language development? Jun 09, 2023 pm 06:40 PM

In PHP language development, date formatting errors are a common problem. The correct date format is very important to programmers because it determines the readability, maintainability and correctness of the code. This article will share some tips for dealing with date formatting errors. Understanding date formats Before dealing with date formatting errors, we must first understand date formats. A date format is a string of various letters and symbols used to represent a specific date and time format. In PHP, common date formats include: Y: four-digit year (such as 20

How to use DateFormat function in Java for date formatting How to use DateFormat function in Java for date formatting Jun 26, 2023 pm 05:01 PM

Java is a popular programming language that includes many powerful tools for date and time manipulation. One of the most commonly used tools is the DateFormat function, which can format date data into a specific string format. This article will introduce how to use the DateFormat function in Java for date formatting. Import the Date and DateFormat classes. Before starting to use the DateFormat function, we need to import the Date and DateFormat classes in Java.

How to use Python regular expressions for date formatting How to use Python regular expressions for date formatting Jun 22, 2023 pm 08:25 PM

Python regular expression is a very powerful text processing tool that can perform operations such as matching, replacing, and extracting strings. In actual development, we often need to format dates, such as converting "2022/10/01" into the format of "October 01, 2022". This article will introduce how to use Python regular expressions for date formatting. 1. Overview of Python regular expressions Python regular expression is a special string pattern, which describes a series of characters that match a certain

PHP time processing skills: quickly calculate time difference and date formatting PHP time processing skills: quickly calculate time difference and date formatting Mar 01, 2024 am 08:54 AM

PHP Time Processing Tips: Quickly Calculate Time Difference and Date Formatting With the rapid development of the Internet, time processing has become one of the common tasks in web development. In PHP, time processing is a relatively common requirement, such as calculating time differences, formatting dates, and other operations. This article will introduce some PHP time processing techniques, including quickly calculating time differences and date formatting, and come with some specific code examples. Calculating the time difference In many application scenarios, we need to calculate the time difference between two time points, such as calculating the time difference between two time points.

Solution to Java date formatting exception (DateTimeParseException) Solution to Java date formatting exception (DateTimeParseException) Aug 19, 2023 pm 03:36 PM

Solution Overview to Solve Java Date Formatting Exception (DateTimeParseException): In Java, date formatting is a common task. We can convert date and time to a specified format by using the SimpleDateFormat class or the new date time APIs available in Java 8 (such as DateTimeFormatter). However, sometimes when formatting dates, you may encounter DateTimePars

How to use date and time functions for date calculation and formatting in Java How to use date and time functions for date calculation and formatting in Java Oct 20, 2023 am 11:24 AM

How to use date and time functions in Java for date calculation and formatting In Java, date and time are very common and important data types. In order to facilitate the processing of dates and times, Java provides a wealth of date and time functions that can perform date calculation, formatting and other operations. Below is a detailed introduction to how to use date and time functions in Java, along with code examples. 1. Date calculation to obtain the current date. Use the java.time.LocalDate class to obtain the current date. Example code

How PHP handles date and time issues How PHP handles date and time issues Jun 30, 2023 am 08:37 AM

Overview of how to deal with date and time processing issues in PHP development: In the PHP development process, date and time processing are very common requirements. Whether you are dealing with user registration time, scheduling, or statistical analysis of data, it is very important to handle dates and times accurately. This article will introduce some commonly used PHP date and time processing functions and some practical experience. Get the current date and time In PHP, you can use the date function to get the current date and time. The syntax of the date function is as follows: stringd

PHP formats a local time/date PHP formats a local time/date Mar 21, 2024 pm 02:30 PM

This article will explain in detail about formatting a local time/date in PHP. The editor thinks it is quite practical, so I share it with you as a reference. I hope you can gain something after reading this article. PHP Formatting Local Time/Date Formatting local time and date is a common task in PHP and can be achieved through PHP's built-in functions and classes. Built-in functions PHP provides several built-in functions to format time and date: date(): used to format the current time and date and return the result according to the provided format string. strftime(): Similar to date(), but it uses the POSIX strftime() function to provide more advanced formatting options. format parameter date

See all articles