12/24 Hour Time format Using Asp.Net C#

   12/24 Hour Time format

Current System Datetime or Server Datetime convert to 12/24 Hour format.

                    Html Coding


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>12/24 Hour Time format Using Asp.Net C#</title>
</head>
<body>
    <form id="form1" runat="server">
    <div align="center">
        <br />
        <asp:Label ID="lblTimeFormat" runat="server" Text="Label"></asp:Label>    </div>
    </form>
</body>

</html>
                      C# Coding


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Default3 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        lblTimeFormat.Text = DateTime.Now.ToString();
        // 24 hour Time Format
        lblTimeFormat.Text = DateTime.Now.ToString("HH:mm");
        //// 12 Hour Time Format
        lblTimeFormat.Text = DateTime.Now.ToString("hh:mm");
        //// 24 Hour with Seconds
        lblTimeFormat.Text = DateTime.Now.ToString("HH:mm:ss");
        //// 12 Hour with Seconds
        lblTimeFormat.Text = DateTime.Now.ToString("hh:mm:ss");
        //// 24 Hour with AM or PM
        lblTimeFormat.Text = DateTime.Now.ToString("HH:mm:ss tt");
        //// 12 Hour with AM or PM
        lblTimeFormat.Text = DateTime.Now.ToString("hh:mm:ss tt");
        // 24 Hour with Month display
        lblTimeFormat.Text = DateTime.Now.ToString("dd/MMM/yyyy HH:mm:ss tt");
        // 24 Hour with 3 Character Day display
        lblTimeFormat.Text = DateTime.Now.ToString("ddd/MMM/yyyy HH:mm:ss tt");
        // 24 Hour with Month & Day display
        lblTimeFormat.Text = DateTime.Now.ToString("d/MMM/yyyy HH:mm:ss tt");
        // 24 Hour with Full Day display
        lblTimeFormat.Text = DateTime.Now.ToString("dddd/MMM/yyyy HH:mm:ss tt");
        // 24 Hour with 3 Character Day display
        lblTimeFormat.Text = DateTime.Now.ToString("ddd/MMMM/yyyy HH:mm:ss tt");
        // 12 Hour with Hour display
        lblTimeFormat.Text = DateTime.Now.ToString("dd/MMMM/yyyy h:mm:ss");
        // 24 Hour with Hour display
        lblTimeFormat.Text = DateTime.Now.ToString("dd/MMMM/yyyy H:mm:ss");

    }

}


// Current Datetime


        DateTime.Now.ToString();

                        Demo

                                    

// 24 hour Time Format
      
     DateTime.Now.ToString("HH:mm");

                         Demo
                                          

 //// 12 Hour Time Format

      DateTime.Now.ToString("hh:mm");
       
                          Demo

                                           

 //// 24 Hour with Seconds

         DateTime.Now.ToString("HH:mm:ss");

                Demo

                                       
//// 12 Hour with Seconds

      DateTime.Now.ToString("hh:mm:ss");

                 Demo

                                           
//// 24 Hour with AM or PM

 DateTime.Now.ToString("HH:mm:ss tt");
        
                  Demo 

                                         

 //// 12 Hour with AM or PM

       DateTime.Now.ToString("hh:mm:ss tt");
               
                 Demo 
                           
                         

 // 24 Hour with Month display

DateTime.Now.ToString("dd/MMM/yyyy HH:mm:ss tt");

                 Demo 
                      
                             
 // 24 Hour with 3 Character Day display

DateTime.Now.ToString("ddd/MMM/yyyy HH:mm:ss tt");

                 Demo 

        

// 24 Hour with Month & Day display

 DateTime.Now.ToString("d/MMM/yyyy HH:mm:ss tt");

                 Demo 

          

        // 24 Hour with Full Day display

DateTime.Now.ToString("dddd/MMM/yyyy HH:mm:ss tt");
      
                  Demo 

           

   // 24 Hour with 3 Character Day display

    DateTime.Now.ToString("ddd/MMMM/yyyy HH:mm:ss tt");

                 Demo 

       
        // 12 Hour with Hour display

 DateTime.Now.ToString("dd/MMMM/yyyy h:mm:ss");

                 Demo 
         

        // 24 Hour with Hour display

 DateTime.Now.ToString("dd/MMMM/yyyy H:mm:ss");

                  Demo 

           


  



String Function Using Javascript and C# in Asp.Net

String Function Using Javascript and C#

String Function uppercase,index,substring Using Javascript and C# in Asp.Net.

                                 DEMO




Html Coding

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript">

        //String Concatination

        function concat()
            {
                var Str1 = "Dot";
                var Str2 = "Net";
                var c = Str1.concat(Str2.toString());
                alert(c.toString());           
            }
       
        //String IndexOf

        function indexof()
        {
            var str1 = "Welcome to Dotnet Drizzles";
           alert(str1.indexOf("Dotnet").toString());

        }

        //String  UpperCase
        function Ucase()
        {
           var Str1 = "Dotnet Drizzzles";
            alert(Str1.toUpperCase());

        }

        // String Last indexof
        function LastIndexof()
        {
           var str1 = "Welcome To Dotnet  Drizzles and Asp Dotnet";
            alert(str1.lastIndexOf("Dotnet"));
        }

        // String Substrings
        function Substring()
        {
            var str1 = "DRIZZLES";

            alert("Substr="+str1.substr(2,3)+","+"Substring="+str1.substring(2,3));
        }

        // String Replace

        function replac()
        {
            var str1 = "Dotnet";
            alert(str1.replace("Dotnet", "DotnetDrizzles"));
        }



    </script>
</head>
<body>
    <form runat="server">
<div align="center">
    <table>
         <tr><td>Javascript</td><td>C#</td></tr>
        <tr><td><input type="button" value="Concat"  onclick="concat();" /></td><td><asp:Button ID="Button1" runat="server" Text="Concat" OnClick="Button1_Click1" /></td></tr>
        <tr><td>         <input type="button" value="IndexOf" onclick="indexof();" />
</td><td>        <asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="IndexOf" />
</td></tr>
        <tr><td>        <input type="button" value="LastIndexOf" onclick="LastIndexof();" />
</td><td>        <asp:Button ID="Button4" runat="server" OnClick="Button4_Click" Text="LastIndexOf" />
</td></tr>
        <tr><td>          <input type="button" value="Uppercase" onclick="    Ucase();" />
</td><td>        <asp:Button ID="Button3" runat="server" OnClick="Button3_Click" Text="Uppercase" />
</td></tr>
        <tr><td>         <input type="button" value="Substring" onclick="Substring();" />
</td><td>        <asp:Button ID="Button5" runat="server" OnClick="Button5_Click" Text="Substring" />
</td></tr>
        <tr><td>  <input type="button" value="Replace" onclick="replac();" />     
</td><td><asp:Button ID="Button6" runat="server" OnClick="Button6_Click" Text="Replace" /></td></tr>
        <tr><td colspan="2"><asp:Label ID="Label1" ForeColor="Red" runat="server" Text="Label"></asp:Label></td></tr>
    </table>        
    </div>
   </form>
</body>
</html>

                     C# Coding


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;

public partial class StringFunctions : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }   
    protected void Button1_Click1(object sender, EventArgs e)
    {
        //Concat
        string  Str1 = "DotNet ";
        string  Str2 = "Drizzles";
        Label1.Text = Str1 + Str2;
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        //IndexOf
        string Str1 = "Welcome to Dotnet Drizzles";
        Label1.Text = Str1.IndexOf("Dotnet").ToString();       
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        //UpperCase
        string Str1 = "Dotnet Drizzzles";
        Label1.Text = Str1.ToUpper();
    }
    protected void Button4_Click(object sender, EventArgs e)
    { 
        //LastIndexOf Dotnet in str1

        string str1 = "Welcome To Dotnet  Drizzles and Asp Dotnet";
        Label1.Text = str1.LastIndexOf("Dotnet").ToString();

    }
    protected void Button5_Click(object sender, EventArgs e)
    { 
        //Substring
        string str1 = "DRIZZLES";
        Label1.Text = str1.Substring(2,3).ToString();
    }
    protected void Button6_Click(object sender, EventArgs e)
    {
        //Replace
        string str1 = "Dotnet";
        Label1.Text = str1.Replace("Dotnet", "DotnetDrizzles");
    }

}

First Create New Webform - Add Buttons & Label for Required - Add String Function in Javascript Script - Next Call Related Function




Next -  Button click Event - Add String function Using C#