javascript method for displaying Chinese dates

  • 2020-06-19 09:37:35
  • OfStack

This article gives an example of how javascript displays Chinese dates. Share to everybody for everybody reference. Specific implementation methods are as follows:

Add the following code to HEML's < body > < /body > between


<script LANGUAGE="JavaScript">
function number(index1){
var numberstring="12345678910";
if(index1 ==0) {document.write("10")}
if(index1 < 10){
document.write(numberstring.substring(0+(index1-1),index1))}
else if(index1 < 20 ){
document.write("10"+numberstring.substring(0+(index1-11),(index1-10)))}
else if(index1 < 30 ){
document.write("210"+numberstring.substring(0+(index1-21),(index1-20)))}
else{
document.write("310"+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(" A.D. 2 In 000, ")
number(month)
document.write(" month ")
number(date)
document.write(" day </small><center>")
</script>

I hope this article has been helpful for your javascript programming.


Related articles: