JavaScriptは現在の時間、時間比較、時間変換を取得します.


//    
<script type="text/javascript">
<!--
var myDate = new Date();
    myDate.getYear();      //      (2 )
    myDate.getFullYear(); //       (4 ,1970-????)
    myDate.getMonth();      //      (0-11,0  1 )
    myDate.getDate();      //     (1-31)
    myDate.getDay();        //      X(0-6,0     )
    myDate.getTime();      //      ( 1970.1.1      )
    myDate.getHours();      //       (0-23)
    myDate.getMinutes();    //       (0-59)
    myDate.getSeconds();    //      (0-59)
    myDate.getMilliseconds(); //       (0-999)
    myDate.toLocaleDateString();    //      
    var mytime=myDate.toLocaleTimeString();    //      
    myDate.toLocaleString( );      //       ----        ,      。
if (mytime<"23:30:00"){
    alert(mytime);
}
//-->
</script>



//    
<script type="text/javascript">
function check(){
        var riqi1 = document.getElementById("begin_time").value;
        var riqi2 = document.getElementById("end_time").value; 
        var datePattern = /^(\d{4})-(\d{1,2})-(\d{1,2})$/;
	//alert(seller+zffs + jyzt+pid + pname);
	if(riqi1 == "" && riqi2 !=""){
		if (! datePattern.test(riqi2)) {
		window.alert("             ");
		return false;
		} 
		alert("       !");
		return false;
	}
	if(riqi1 != "" && riqi2 ==""){
		if (! datePattern.test(riqi1)) {
		window.alert("             ");
		return false;
		}
		alert("       !");
		return false;
	}
	if(riqi1 !="" && riqi2 !=""){
		var datePattern = /^(\d{4})-(\d{1,2})-(\d{1,2})$/;
		if (! datePattern.test(riqi1)) {
			window.alert("             ");
			return false;
		}
		if (! datePattern.test(riqi2)) {
			window.alert("             ");
			return false;
		} 
	}
    	
	var d1 = new Date(riqi1.replace(/-/g,"/"));
	var d2 = new Date(riqi2.replace(/-/g,"/"));
	if (Date.parse(d1) - Date.parse(d2) >= 0) {
		alert("            !");
		return false;
	}