JSP method for obtaining the current server Date and Time

Source: Internet
Author: User

JSP method for obtaining the current server Date and Time

<Script language = "JavaScript">
VaR mydate = new date ();
Mydate. getyear (); // obtain the current year (2 digits)
Mydate. getfullyear (); // obtain the complete year (4 bits, 1970 -????)
Mydate. getmonth (); // obtain the current month (0-11, 0 represents January)
Mydate. getdate (); // obtain the current day (1-31)
Mydate. getday (); // obtain X of the current week (0-6, 0 indicates Sunday)
Mydate. gettime (); // obtain the current time (milliseconds starting from 1970.1.1)
Mydate. gethours (); // obtain the current hour (0-23)
Mydate. getminutes (); // obtain the current number of minutes (0-59)
Mydate. getseconds (); // obtain the current number of seconds (0-59)
Mydate. getmilliseconds (); // obtain the current number of milliseconds (0-999)
Mydate. tolocaledatestring (); // obtain the current date www.setas.com
VaR mytime = mydate. tolocaletimestring (); // obtain the current time
Mydate. tolocalestring (); // obtain the date and time

If (mytime <"23:30:00 ")
{
Alert (mytime );
}
</SCRIPT>

<%
Java. Text. simpledateformat formatter = new java. Text. simpledateformat ("yyyy-mm-dd hh: mm: SS ");
Java. util. Date currenttime = new java. util. Date (); // obtain the current system time
String str_date1 = formatter. Format (currenttime); // format the date and time.
String str_date2 = currenttime. tostring (); // converts a date to a string.
%>

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.