ASP.Net/Language Basics/Date Format
Содержание
Date Time Format: (C#)
<%@ Page Language="C#" Debug="true"%>
<script runat="server">
void Page_Load()
{
if (Page.IsPostBack)
{
DateTime MyDateTime;
MyDateTime = Convert.ToDateTime("1/1/2005 16:25:05");
lblDateOut.Text = Convert.ToString(MyDateTime); //reads the variable
}
}
</script>
<html>
<head>
<title>Variables Example - String and Char</title>
</head>
<body>
<form runat="server">
<asp:Label runat="server" ID="lblDateOut" >Label</asp:Label><br>
<asp:Button runat="server" Text="Click me format date time"></asp:Button>
</form>
</body>
</html>
DateTime format: 5 (C#)
<%@ Page Language="C#" Debug="true"%>
<script runat="server">
void Page_Load()
{
if (Page.IsPostBack)
{
DateTime MyDateTime;
MyDateTime = Convert.ToDateTime("1/1/2005");
lblDateOut.Text = Convert.ToString(MyDateTime); //reads the variable
}
}
</script>
<html>
<head>
<title>Variables Example - String and Char</title>
</head>
<body>
<form runat="server">
<asp:Label runat="server" ID="lblDateOut" >Label</asp:Label><br>
<asp:Button runat="server" Text="Click me format date time"></asp:Button>
</form>
</body>
</html>
Date Time Format: (C#)
<%@ Page Language="C#" Debug="true"%>
<script runat="server">
void Page_Load()
{
if (Page.IsPostBack)
{
DateTime MyDateTime;
MyDateTime = Convert.ToDateTime("16:25:05");
lblDateOut.Text = Convert.ToString(MyDateTime); //reads the variable
}
}
</script>
<html>
<head>
<title>Variables Example - String and Char</title>
</head>
<body>
<form runat="server">
<asp:Label runat="server" ID="lblDateOut" >Label</asp:Label><br>
<asp:Button runat="server" Text="Click me format date time"></asp:Button>
</form>
</body>
</html>
Date time Format: PM (C#)
<%@ Page Language="C#" Debug="true"%>
<script runat="server">
void Page_Load()
{
if (Page.IsPostBack)
{
DateTime MyDateTime;
MyDateTime = Convert.ToDateTime("4:25:05 PM");
lblDateOut.Text = Convert.ToString(MyDateTime); //reads the variable
}
}
</script>
<html>
<head>
<title>Variables Example - String and Char</title>
</head>
<body>
<form runat="server">
<asp:Label runat="server" ID="lblDateOut" >Label</asp:Label><br>
<asp:Button runat="server" Text="Click me format date time"></asp:Button>
</form>
</body>
</html>