<script>var mydate = new Date (); Mydate.getyear (); Gets the current year (2-bit)//alert (Mydate.getyear ())//2009 mydate.getfullyear (); Get the full year (4-bit, 1970-????) Alert (Mydate.getfullyear ()); Mydate.getmonth (); Get the current month (0-11, 0 for January)//alert (Mydate.getmonth ()); 7 (actually August) mydate.getdate (); Get current day (1-31)//alert (Mydate.getdate ()); Mydate.getday (); Get Current week x (0-6, 0 for Sunday)//alert (Mydate.getday ()); 4 represents Thursday mydate.gettime (); Gets the current time (the number of milliseconds starting in 1970.1.1) mydate.gethours (); Gets the current number of hours (0-23)//alert (Mydate.gethours ()); 9 stands for 9 points mydate.getminutes (); Gets the current number of minutes (0-59)//alert (Mydate.getminutes ()); 45 min mydate.getseconds (); Gets the current number of seconds (0-59)//alert (Mydate.getseconds ()); 40 seconds number mydate.getmilliseconds (); Gets the current number of milliseconds (0-999) mydate.tolocaledatestring (); Gets the current date var mytime=mydate.tolocaletimestring (); Get current time//alert (mytime);//9:40:18 mydate.tolocalestring (); Get date and Time//alert (Mydate.tolocalestring ()); August 13, 2009 9:40:58</script>
<script>function Curdatetime () { var d = new Date (); var year = D.getyear (); var month = D.getmonth () + 1; var date = D.getdate (); var day = D.getday (); var curdatetime = year; if (Month > 9) curdatetime = curdatetime + month; else curdatetime = curdatetime + "0" + month; if (Date > 9) curdatetime = curdatetime + date; else curdatetime = curdatetime + "0" + date; Myform.kprq.value = Curdatetime; Alert ("Current date" +curdatetime); Document.getelementbyidx_x ("date"). Value=curdatetime; </script>
function Curdatetime () { var d = new Date (); var year = D.getfullyear (); var month = D.getmonth () + 1; var date = D.getdate (); var day = D.getday (); var curdatetime = year; if (Month > 9) curdatetime = Curdatetime + "-" + month; else curdatetime = curdatetime + "-0" + month; if (Date > 9) curdatetime = Curdatetime + "-" + date; else curdatetime = curdatetime + "-0" + date; return curdatetime; }
JS Gets the current date time