Home > Web Front-end > JS Tutorial > js date conversion function into Chinese format_javascript skills

js date conversion function into Chinese format_javascript skills

WBOY
Release: 2016-05-16 18:50:30
Original
1362 people have browsed it
Copy code The code is as follows:

function CNDateString(date)
{
var cn = ["〇","一","二","三","四","五","六","七","八","九"];
var s = [] ;
var YY = date.getFullYear().toString();
for (var i=0; iif (cn[YY.charAt(i)])
s.push(cn[YY.charAt(i)]);
else
s.push(YY.charAt(i));
s.push("Year");
var MM = date.getMonth();
if (MM<10)
s.push(cn[MM]);
else if (MM<20)
s.push( "十" cn[MM% 10]);
s.push("month");
var DD = date.getDate();
if (DD<10)
s.push (cn[DD]);
else if (DD<20)
s.push("十" cn[DD% 10]);
else
s.push("Twenty" cn[DD% 10]);
s.push("日");
return s.join('');
}

Example:
alert(CNDateString(new Date())); Get: July 12, 2009
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template