CountryDate cd = new CountryDate();
string ChineseTimeNow = cd.GetChineseDate(DateTime.Now);//农历日期
string ForignTimeNow = DateTime.Now.GetDateTimeFormats('D')[0].ToString();//公历日期
下面有一个测试的效果:
前台代码:
复制代码 代码如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TestCountryDate._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form runat="server">
<div>
<table>
<tr>
<td><asp:Label runat="server" Text="农历时间"/></td>
<td><asp:Label runat="server"/></td>
</tr>
<tr>
<td><asp:Label runat="server" Text="公历时间"/></td>
<td><asp:Label runat="server"/></td>
</tr>
</table>
<asp:Button runat="server" Text="显示时间" />
</div>
</form>
</body>
</html>
后台代码:
复制代码 代码如下: