<script>
var
s=[
"2008-8-1"
,
"2009/9/2"
,
"10/3/2010"
];
for
(
var
i=0;i<s.length;i++){
var
d = string2date(s[i]);
var
year = d.getFullYear();
var
month = d.getMonth()+1;
var
date = d.getDate();
var
dateStr = year+
" 年 "
+month+
" 月 "
+ date+
" 日"
;
alert(
"原始串:"
+s[i]+
"
直接转:"
+
new
Date(s[i])+
"
用方法转:"
+dateStr);
}
function
string2date(str){
return
new
Date(Date.parse(str.replace(/-/g,
"/"
)));
}
</script>