<tfoot id="scysq"></tfoot>
<tfoot id="scysq"></tfoot>
<strike id="scysq"></strike>
  • <ul id="scysq"><sup id="scysq"></sup></ul>

    JSP網(wǎng)站建設(shè)常用的獲取時間的代碼

    更新時間:2021-12-21 編輯:創(chuàng)始人 關(guān)注人次:0 云搜索


    <%@ page contentType="text/html;charset=utf-8"%>
    <html>
    <body onload="disptime();">
    <FORM NAME="myform">
    <DIV align="center">
    <SCRIPT language="JavaScript">
    <!--
    function disptime( )
    {
    var time = new Date( ); //獲得當前時間
    var year = time.getYear( );//獲得年、月、日
    var month = time.getMonth( );
    var day = time.getDay( );
    var hour = time.getHours( ); //獲得小時、分鐘、秒
    var minute = time.getMinutes( );
    var second = time.getSeconds( );
    var apm="AM"; //默認顯示上午: AM
    if (hour>12) //按12小時制顯示
    {
    hour=hour-12;
    apm="PM" ;
    }
    if (minute < 10) //如果分鐘只有1位,補0顯示
    minute="0"+minute;
    if (second < 10) //如果秒數(shù)只有1位,補0顯示
    second="0"+second;
    /*設(shè)置文本框的內(nèi)容為當前時間*/
    document.myform.myclock.value =year+"年"+month+"月"+day+"日 "+hour+":"+minute+":"+second+" "+apm;
    /*設(shè)置定時器每隔1秒(1000毫秒),調(diào)用函數(shù)disptime()執(zhí)行,刷新時鐘顯示*/
    var myTime = setTimeout("disptime()",1000);
    }
    //-->
    </SCRIPT>
    動態(tài)顯示時間<INPUT name="myclock" type="text" value="" size="25">
    <br>
    靜態(tài)顯示時間 <%=new java.util.Date()%>
    </body></html>


    本文地址: http://www.770551.com/show-239.html ,轉(zhuǎn)載請注明出處。

    服務(wù)支持

    我們珍惜您每一次在線詢盤,有問必答,用專業(yè)的態(tài)度,貼心的服務(wù)。

    讓您真正感受到我們的與眾不同!