<SCRIPT language=JavaScript>
<!--
//以下是年月日星期显示
tmpDate=new Date()date=tmpDate.getDate()month=tmpDate.getMonth()+1year=tmpDate.getFullYear()document.write(year)document.write("年")document.write(month)document.write("月")document.write(date)document.write("日")document.write(" ")myArray=new Array(6)myArray[0]="星期日 "
myArray[1]="星期一 "
myArray[2]="星期二 "
myArray[3]="星期三 "
myArray[4]="星期四 "
myArray[5]="星期五 "
myArray[6]="星期六 "
weekday=tmpDate.getDay()if(weekday==0|weekday==6)
{document.write(myArray[weekday])
}else
{document.write(myArray[weekday])
}
//-->
</SCRIPT>
<pre t="code" l="js">function getTime(date){
if(date == null)
{
date = new Date()
}
var y = date.getFullYear()
var M = date.getMonth() + 1
var d = date.getDate()
var h = date.getHours()
var m = date.getMinutes()
var s = date.getSeconds()
var S = date.getTime()%1000
var html = y + "-"
if(M <10)
{
html += "0"
}
html += M + "-"
if(d <10)
{
html += "0"
}
html += d + " "
if(h <10)
{
html += "0"
}
html += h + ":"
if(m <10)
{
html += "0"
}
html += m + ":"
if(s <10)
{
html += "0"
}
html += s
html += " "
if(S <100)
{
html += "0"
}
if(S <10)
{
html += "0"
}
html += S
return html
}
alert(getTime(new Date()))
var arr = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]var str = "January 25, 2014"
var mon = str.match(/[a-zA-Z]+/)[0]
var temp = arr.join(",").split(mon + ",")[0].match(/,/g)
var len = !!temp ? temp.length + 1 : 1
str = str.replace(mon, len)
.replace(/\s*(\d+)\s+(\d+)\s*,\s*(\d+)\s*/,"$3-$1-$2")
.replace(/\-(\d)\b/g,"-0$1")
console.log(str)