JS Get Current date time + date validation + judgment leap Year + date difference + date formatting +js Judging How many days a certain monthString to date type +js current datetime + date validation + judgment leap Year + date difference + date
JSON date to JS date, we know that after the date type is converted to JSON, the returned data looks like this:
/date (1379944571737)/
But this date does not appear directly, because no one knows what it means, and here's a way to turn the JSON
This article mainly introduces how to get the summary of current date and time and other date operations by js. Interested partners can refer to the examples in this article to share common scenarios of javascript time operations, for your reference,
Js obtains the summary of current date and time and other date operations.
The examples in this article share common scenarios of javascript time operations for your reference. The specific content is as follows:
Var myDate = new Date (); myDate.
The following summarizes the implementation methods for obtaining a specified date in Java. For more information, seeCopy codeThe Code is as follows:Format a Date String --> Date or Data --> String
SimpleDateFormat sdf = new SimpleDateFormat
Date and Time script library method list Date. prototype. isLeapYear judge leap year
Date. prototype. Format
Date. prototype. DateAdd Date calculation
Date. prototype. DateDiff compare Date difference
Date. prototype. toString Date to string
Date.
Java get millisecond: system. currenttimemillis () Java get nanosecond: system. nanotime () (used to get very accurate time, recommended !) Java obtains the current date: gregoriancalendar date_1 = (gregoriancalendar) calendar. getinstance (); Java.
A relatively good js Date and Time Acquisition Function is comprehensive and easy to expand. MyDate. getYear (); // obtain the current year (2 digits)
MyDate. getFullYear (); // obtain the complete year (4 bits, 1970 -????)
MyDate. getMonth (); //
It is convenient to use timestamp to record datetime, but sometimes it is not necessary to display the milliseconds after the decimal point, so you need to redefine the format when converting to string. timestamp converted to string:
JS to obtain the current date and time and other operations 2008-07-28-06-11 17: 24var mydate = new date ();Mydate. getyear (); // obtain the current year (2 digits)Mydate. getfullyear (); // obtain the complete year (4 bits, 1970 -????)Mydate.
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.