JavaScript Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21st 22 23 24 25 26 27 28 |
|
<script> Window.onload =function(){ Date.prototype. Format =function(FMT) { varo = { "m+": This. GetMonth () +1, Month "d+": This. GetDate (),//day "H +": This. GetHours (),//hour "m+": This. getminutes (),//min "S+": This. getseconds (),//sec "q+": Math.floor (( This. GetMonth () +3) / 3), //Quarterly "S": This. Getmilliseconds ()//MS }; if(/(y+)/.test (FMT)) FMT = Fmt.replace (regexp.$1, ( This. getFullYear () +""). substr (4-regexp.$1.length)); for (varkinchO if (NewRegExp ("("+ k +")"). Test (FMT)) FMT = Fmt.replace (regexp.$1, (regexp.$1.length = =1) ? (O[k]): (("XX"+ o[k]). substr (""+ o[k])); returnFMT; }
varcurrenttime1 =NewDate (). Format ("Yyyy-mm-ddthh:mm:ss"); varPselstart = document.getElementById ("StartTime"); Pselstart.value = currenttime1; varcurrenttime2 =NewDate (). Format ("Yyyy-mm-ddthh:mm:ss"); varpselend = document.getElementById ("Endtime"); Pselend.value = currenttime2; } </script> |
JavaScript formatted date output