Home > Web Front-end > JS Tutorial > How to display Chinese date in javascript_javascript skills

How to display Chinese date in javascript_javascript skills

WBOY
Release: 2016-05-16 15:54:18
Original
1278 people have browsed it

The example in this article describes the method of displaying Chinese date in javascript. Share it with everyone for your reference. The specific implementation method is as follows:

Add the following code between HEML

<script LANGUAGE="JavaScript">
function number(index1){
var numberstring="一二三四五六七八九十";
if(index1 ==0) {document.write("十")}
if(index1 < 10){
document.write(numberstring.substring(0+(index1-1),index1))}
else if(index1 < 20 ){
document.write("十"+numberstring.substring(0+(index1-11),(index1-10)))}
else if(index1 < 30 ){
document.write("二十"+numberstring.substring(0+(index1-21),(index1-20)))}
else{
document.write("三十"+numberstring.substring(0+(index1-31),(index1-30)))}
}
var today1 = new Date()
var month = today1.getMonth()+1
var date = today1.getDate()
var day = today1.getDay()
document.write("<br><strong><small><center>")
document.write("公元二零零零年")
number(month)
document.write("月")
number(date)
document.write("日</small><center>")
</script>
Copy after login

I hope this article will be helpful to everyone’s JavaScript programming design.

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