Declare a variable in time

I need to create a variable containing time in the format hh: mm, how to do it?

DateTime currentTime = "00:00";

doesn't seem to do the trick. I need to add hours / minutes to the loop to this variable and save the format "hh: mm". How it's done?

/ M

+5
source share
6 answers

Perhaps used for this TimeSpan?

+12
source

You must distinguish between the amount you are trying to track and the possible formatting of the string. They are different.

( DateTime , , ) ( TimeSpan )? , , , .

( -, Noda Time, ; Joda Time Java. -, , :)

+8

DateTime current;
DateTime.TryParse("13:00", out current);

,

current.ToString("hh:mm");
+3
source

Timespan is your best bet or use DateTime.toString ("hh: mm")

+2
source

You can use the regular datetime variable with the current date starting at midnight.

0
source

A prime integer? hours = number / 60; minutes = number % 60

0
source

All Articles