<script type= "Text/javascript" src= "http://code.jquery.com/jquery-latest.js" ></script> <script type = "Text/javascript" > $(function() {/** Date Formatting*/Date.prototype.format=function(format) {varo = { "m+": This. GetMonth () + 1,//Month"D+": This. GetDate (),// Day"H +": This. GetHours (),//Hour"m+": This. getminutes (),//minute"S+": This. getseconds (),//Second"q+": Math.floor (( This. GetMonth () + 3)/3),//Quarter"S": This. Getmilliseconds ()//Millisecond } if(/(y+)/. Test (format)) format= Format.replace (Regexp.$1, ( This. getFullYear () + ""). substr (4-regexp.$1. length)); for(varKinchOif(NewRegExp ("(" + K + ")"). Test (format)) format= Format.replace (regexp.$1, regexp.$1.length = = 1? O[k]: ("XX" + o[k]). substr ("" +O[k]) (length)); returnformat; } varDate =NewDate (); Alert (date.gethours ()+ "_" +date.getminutes () + "_" +date.getseconds ()) Alert (Date.format (' Yyyy-mm-dd ') alert (Date.format (' Hh-mm-ss ')) }) </script>
JS date Formatting