Date object extension, including common Chinese Date Format Parsing, addition and subtraction operations, Date difference, week operations, and quarter operations. Today, I have excerpted some methods related to date operations in js on the Internet.
Date object formatting method. For more information, see.
The Code is as follows:
/** Date Format 1.2.3* (C) 2007-2009 Steven Levithan* MIT license** Includes enhancements by Scott Trenda* And Kris Kowal** Accepts a date, a mask, or a date and a
-How to get and set timeUse date objects to make the corresponding effects1. Set the timeCreate a Time objectNew Date (time);Set timeFrom January 1, 1970 toSeveral formats:New Date ("May 25, 2024");New Date ("2015/12/25,12:20:12");New Date (2016,1,1)
1.Date objects
Create
var date1 = new Date ();var date2 = new Date (12983798123);//fill in a millisecond value, it should be from January 1, 1970 ..... How many milliseconds
Method
1.new date () Get local
I. El expressions
First, introduce tags, On the JSP page.
Second, use the El expression as the value of the FMT tag attribute. Add the pattern parameter to specify the format to be formatted for the date, for example, yyyy-mm-dd. For example:
// Constructor new date (milliseconds) // new date (year, month, day, hours, minutes, seconds, MS) // PS: month parameter range: 0-11 // key point: the date object is converted to a string in the specified format, and the string is converted to a
Let's talk about this Application Scenario:
Read data from the XML file, and then return the data to the page using a third-party plug-in for plotting.
The data read in XML is of course a string type, and if you want to use the time mode of the X
2015-03-28 17:20:18There are two methods of solving this problem:The first type:The second chapter solution:The second method is generally used to take the point, the first fit to take the range, so the question of this range of the problem, it is
To get the system time in Java:Date date = new Date ();toLocaleString () Converts the resulting event into a local time formatTo get the system time in JS:var date = new Date ();toLocaleString () Converts the resulting event into a local time
JS on string, array, date operation is the most frequently used in future projects, so .... So we look at it, in fact, not difficult ha, is a bit boring, I admit that this is my Baidu, haha hahajavascript String Object JS string, array, time, Date
GetYear ()The intent of using the getyear () function is to obtain the year, taking 2010 as an example, such as:
var nowd = new Date ();
var YF = Nowd.getyear ();
In IE, the year can be obtained correctly: 2010, but under the FF
Math
Min asks the minimum value in a group of books to return number
Max asks the maximum value in a set of books to return number
Ceil rounding up
Floor returns an integral number of parts
Round rounding
ABS Absolute
Previous wordsA simple calendar is a common application for date objects in JavaScript, and is widely used. This article will explain in detail the realization idea of the simple calendarEffect DemoHTML descriptionTwo inputs using Type=number as
Date is the built-in constructor for JSvar d = new Date (); This is the date instance of the system's current timeD.getyear (); Returns the D instance year-1900D.getfullyear (); Get the full year of the D instanceD.getmonth (); Get D instance month,
The Math.randon () and date objects of this section mainly refer to a date instance and a Math.rando function instance.
Extract an example of information from a Date object
Using the Random function Math.randon () example
Global functions
Date
Static methods for the Date class
Date.parse
Date.utc
Method of establishing Date object
New Date ()
New Date (number of milliseconds)
New Date (Standard Time format string)
New Date (year, month, day, time, minute, second,
The date object is used to process the date and time.Syntax for creating a date object:VaR mydate = new date ()The date object automatically saves the current date and time as its initial value.The following five parameters are supported:
New date
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.