Calculate the JavaScript date subtraction and then obtain the second date. In normal times, the probability of time addition and subtraction is also relatively high. The following JS functions can complete the specified number of days minus a certain number of days and calculate another
This article briefly introduces Date (Date object) and Math object in JavaScript. For more information, see
Date object
1. What is a Date object?
A date object can store any date, and
Java Date and javascript Date
I recently wrote a page showing the date. Generate a Date in Java, and then send the Date to the vm template through velocity.
The Code is as follows:
var dates = new
Code for converting string to date in Javascript
Details about Array object extension and String object extension in JS
The toString () method of the JavaScript Number object
A summary of javascript learning every day (String object)
Three js methods to implement the string substring Method
Analysis of substring
difference.Return Week methodGetDay () returns a number of 0-6 in the week, 0 for Sunday. If you want to return the corresponding "week", complete with the array, the code is as follows:Note: The above code was run on March 7, 2014, Friday.Results:5Today is: Fridayreturn/Set Time methodget/settime () Returns/sets the time, in milliseconds, to calculate the number of milliseconds from January 1, 1970 0 o'clock to the date the
:
document.write (Math.min (2,3,4,6));//2
Gets the minimum value in the array, using the Apply () method:
Copy Code code as follows:
var values=[3,2,1,8,9,7];
document.write (Math.min.apply (math,values) + "
The Math object is the first argument to apply, and any array as the second argument
6): Max () Method: Returns the maximum value in a set of values
Copy Code code as follows:
document.write (Math.max (2,3,4,6));//6
Gets t
No need to talk about the date function? Is the General date comparison, the date addition, get the current time
The Code is as follows:
/** Function name: DateUtil* OPERATOR: yithcn* Function Description: Date Functions* Instructions:* Creation
JavaScript code/// Check whether the input date is in the correct date format:/// Supports four input formats: yyyy-M-d, yyyy-MM-dd, yyyy/M/d, and yyyy/MM/dd.
Function checkDate (strInputDate ){// Define a constant array of months and daysVar DA = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31];
// Unified Date FormatStrDa
Original: JavaScript's date format, which mimics the format of the date command in the shellThe current date is displayed in the shell[[emailprotected]]$ date '+%Y-%m-%d %H:%M:%S'2015-01-19 16:24:58It is inconvenient to format the date object in
JavaScript converts a Date to a string using Date-Mask
This example describes how JavaScript converts a Date to a string using Date-Mask. Share it with you for your reference. The specific implementation method is as follows:
?
Basic usage example of a JavaScript Date object (Date), using criptdate
This example describes the basic usage of a JavaScript Date object. We will share this with you for your reference. The details are as follows:
1. Get the current da
First, paste the javascript code I wrote. You can refer to it later.
The Code is as follows:
Date. prototype. dateAdd = function (interval, number){Var d = this;Var k = {'y': 'fullyear ', 'q': 'month', 'M': 'month', 'w': 'date', 'D ': 'date', 'H': 'urs', 'N': 'minutes ', 's': 'seconds', 'ms': 'milliseconds '};Var n =
This article describes how to initialize the js Date range to get the date of the previous month. it involves related techniques related to the date of javascript operations and is very useful, for more information about how to initialize the js date range, see the following
This article describes how to convert a Date into a string using Date-Mask in JavaScript, involving techniques related to javascript Date, array, and string operations, for more information about how to convert a Date to a string
In JavaScript, we often have to judge the date format, the regular expression is the most efficient, the following is to verify the date format (YYYY-MM-DD) and the date format (YYYY-MM-DD hh: mm: SS) regular expression.
VaR
_ Redatatime
=
/^
([
1
-
9
] D
{3}
-
((
0
?
[
1
-
9
])
|
The example in this article summarizes the method of date formatting in JavaScript. Share to everyone for your reference, specific as follows:
Method One:
An extension to date that converts date to a string
/month (M) in the specified format, days (d), hours (h), minutes (M), seconds (s), quarter (q) can be us
.
Main summary:
1, the use of closures, hidden internal functions and variables to prevent variable pollution. Finally, only one external interface is provided: Setdatestyle
2. The calculation of the number of days per year February is not by judging leap years, but by judging whether February 29 exists or 28 days if it does not exist.
3, the calculation of the week to first calculate the current date is th
, b); Returns a smaller number.Math.Abs (num); Returns the absolute value.Math.ceil (3.6); Rounding up. 4Math.floor (3.6); Rounding down. 3Math.pow (x, y); The Y-side of X.MATH.SQRT (num); Open Square. 4: Trigonometric Functions ReviewMath.sin (x); The sine of x, the return value is between 1 and 1.Math.Cos (x); The cosine of X, and the return value is between 1 and 1.Appendix:Pythagorean theoremvar a = 3, b = 4;var c = math.sqrt (Math.pow (A, 2) + M
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.