Add seconds in existing time ASP.NET example


Using AddSeconds method  you can add seconds in integer, Object will be updated with new date and time. This method is used where you want to calculate time after some seconds. Like Library management project. Lets take an simple example

<form id="form1" runat="server">
    <asp:Button ID="Button1"
    onclick="Button1_Click" Text="Click" />
    <asp:Label ID="Label1"
Code Behind
 protected void Button1_Click(object sender, EventArgs e)
            DateTime now = DateTime.Now;          
            DateTime after56Seconds = now.AddSeconds(56);
            Label1.Text = "present time = " + now.ToLongTimeString();
            Label1.Text += "<br /><br />";
            Label1.Text += "after added 56 seconds with present time= ";
            Label1.Text += after56Seconds.ToLongTimeString();

Code Generate the following output
Add seconds in existing time ASP.NET example


Popular posts from this blog

difference between structure and union in C Language

Difference between Linear search and Binary Search in c language

Difference between static and dynamic websites