Convert DateTime to TimeSpan

前端 未结 5 1681
离开以前
离开以前 2020-12-03 12:56

I want to convert a DateTime instance into a TimeSpan instance, is it possible?

I\'ve looked around but I couldn\'t find what I want, I on

5条回答
  •  爱一瞬间的悲伤
    2020-12-03 13:48

    You can just use the TimeOfDay property of date time, which is TimeSpan type:

    DateTime.TimeOfDay
    

    This property has been around since .NET 1.1

    More information: http://msdn.microsoft.com/en-us/library/system.datetime.timeofday(v=vs.110).aspx

提交回复
热议问题