Days, hours, minutes, seconds between two dates

后端 未结 9 1068
挽巷
挽巷 2020-12-01 07:29

I have two dates, one less than the other. I want to create a string such as this one

\"0 days, 0 hours, 23 minutes, 18 seconds\"

representing the differenc

9条回答
  •  情歌与酒
    2020-12-01 07:54

        DateTime myDay = DateTime.Now;
        DateTime otherDate = DateTime.Now.AddYears(1);
        var test = otherDate.Subtract(myDay);
        Console.WriteLine("Days:" + test.Days + "Hours:" + test.Hours +"Minutes" +  test.Minutes +"Seconds" + test.Seconds);
    

    Here test is of type TimeStamp

提交回复
热议问题