Get ASP's Chinese date string

Source: Internet
Author: User
Tags date end idate
Chinese | string | String we usually need to write the current date on the WEB page, possibly using the client script, or using ASP. One feature of using ASP is that it produces an effect that looks like a static page, but it is actually generated dynamically. If you want to use ASP to display a Chinese date, you need to translate it. Here is the function to transform and its invocation instance.

[[function Implementation]]
[%
'======================================================
' Function Date2chinese
' function: String to get Chinese date (e.g. May 12, 1998)
' Parameter: idate date to convert
' Return: string of Chinese date
'======================================================
Function Date2chinese (Idate)
Dim Num (10)
Dim iyear
Dim Imonth
Dim Iday

num (0) = "0"
num (1) = "One"
num (2) = "Two"
num (3) = "three"
num (4) = "Four"
num (5) = "Five"
num (6) = "Six"
num (7) = "Seven"
num (8) = "Eight"
num (9) = "Nine"

Iyear = year (Idate)
Imonth = Month (Idate)
Iday = Day (Idate)
Date2chinese = num (iyear \ 1000) + _
Num ((iyear) Mod + num (iyear _
MoD) + num (iyear mod _
10) + "year"
If Imonth]= Then
If Imonth = Ten Then
Date2chinese = Date2chinese + _
"Ten" + "month"
Else
Date2chinese = Date2chinese + _
"Ten" + num (imonth Mod 10) + "Month"
End If
Else
Date2chinese = Date2chinese + _
Num (imonth Mod 10) + "Month"
End If
If Iday]= Then
If Iday = Ten Then
Date2chinese = Date2chinese + _
"Ten" + "Day"
ElseIf Iday = Or Iday = Then
Date2chinese = Date2chinese + _
Num (iday \ 10) + "Ten" + "Day"
ElseIf Iday] Then
Date2chinese = Date2chinese + _
Num (iday \ 10) + "Ten" + _
Num (iday Mod 10) + "Day"
Else
Date2chinese = Date2chinese + _
"Ten" + num (iday Mod 10) + "Day"
End If
Else
Date2chinese = Date2chinese + _
Num (iday Mod 10) + "Day"
End If
End Function
%]

[[Call example]]
[%
Response.Write Date2chinese (Date ())
%]



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.