On the JSP page, obtain the current date and time.
1,
<Script language = "JavaScript"> var myDate = new Date (); myDate. getYear (); // obtain the current year (2 digits) myDate. getFullYear (); // obtain the complete year (4 digits, 1970 -????) MyDate. getMonth (); // obtain the current month (0-11, 0 represents January) myDate. getDate (); // obtain the current day (1-31) myDate. getDay (); // obtain the current day X (0-6, 0 represents Sunday) myDate. getTime (); // obtain the current time (milliseconds starting from 1970.1.1) myDate. getHours (); // obtain the current hour (0-23) myDate. getMinutes (); // get the current number of minutes (0-59) myDate. getSeconds (); // obtain the current number of seconds (0-59) myDate. getMilliseconds (); // get the current number of milliseconds (0-999) myDate. toLocaleDateString (); // obtain the current date var mytime = myDate. toLocaleTimeString (); // obtain the current time myDate. toLocaleString (); // obtain the date and time if (mytime <"23:30:00") {alert (mytime) ;}</SCRIPT>
2,
<% 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 String str_date2 = currentTime. toString (); // convert a Date to a string. %>
The above is all the content provided by the editor for you to obtain the method of the current date and time on the JSP page. I hope it will be helpful to you and support more help ~