Date time Format: 4:25:05 PM (C#) : Date Format « Language Basics « ASP.Net





Date time Format: 4:25:05 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>

           
       










Related examples in the same category

1.Date Time Format: 16:25:05 (C#)
2.Date Time Format: 1/1/2005 16:25:05 (C#)
3.DateTime format: 1/1/2005 (C#)