DateTime AddMinutes method not working

后端 未结 6 829
挽巷
挽巷 2021-02-07 23:50

The purpose of my method is to get the currentTime, and set it back for 20 minutes. For what I can see, my method is correct, but the output shows something else.

This

6条回答
  •  爱一瞬间的悲伤
    2021-02-08 00:42

    AddMinutes returns a new DateTime object so you need:

        DateTime currentTime = DateTime.Now;
        double minuts = -20;
        DateTime newTime = currentTime.AddMinutes(minuts);
    
        Console.WriteLine("Nuværende tid: "+newTime);
    

提交回复
热议问题