Solved

How do I add minutes to a specific time in c#.net?

Posted on 2008-10-15
2
1,175 Views
Last Modified: 2013-12-17
I have a text box  that will populate with the current time when you click inside the text box example(6:40pm). I have another text box that users will enter just a number to represent minutes example (30). I have another text box that I want to display the time after adding the minutes entered to the current time.

EXAMPLE 6:40pm + 30 = 7:10pm
0
Comment
Question by:wademi
2 Comments
 
LVL 16

Expert Comment

by:CuteBug
ID: 22727146
Convert the value in the first textbox to DateTime object.
And then call the AddMinutes() method of that object with the data in the second textbox as argument.
0
 
LVL 6

Accepted Solution

by:
carlsiy earned 500 total points
ID: 22727158
Provided that you have 3 TextBoxes.
textBox1 = Current Time
textBox2 = Amount of minutes to be added
textBox3 = Output of textBox1 + textBox2

        private void button4_Click(object sender, EventArgs e)
        {
            textBox3.Text = DateTime.Parse(textBox1.Text).AddMinutes(double.Parse(textBox2.Text)).ToShortTimeString();
        }
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Finding the IIS version 5 37
Where is this file? 3 32
how to just get time from a date 6 46
Error building VS2105 solution from repository 1 31
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question