Solved

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

Posted on 2008-10-15
2
1,165 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now