- Home /
How can I let users add numbers, but in time/hours/minutes?,When button pressed, add X amount of time.
Hi!
I'm making an app that let's you choose a time, and when the DateTime.Now == The chosen time, do something. My only problem is that I don't know how to add e.g. 30 minutes when a button is pressed. (I do know how to add numbers, but not in time ;) )
Kind regards,
Yuri
Comment
Best Answer
Answer by andrew-lukasik · Aug 05, 2020 at 10:51 AM
System.DateTime alarm = System.DateTime.Now;
if( buttonPressed )
{
alarm = now.AddMinutes( 1.0 );
}
This is the basic idea. You can expand on that adding hours, days etc.
Your answer
![](https://koobas.hobune.stream/wayback/20220613004939im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
timer that can be reset 1 Answer
countdown timer acivation 1 Answer
As I can make a timer? 2 Answers
Unity and Playmaker - Flashlight Decrease Logic 0 Answers
Timer counting UP instead of DOWN 1 Answer