Date Time Format: 1/1/2005 16:25:05 (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>
Related examples in the same category