timepicker - Get Current DateTime C# without hour -
hi have timepicker. returns object timespan. need set datetimeoffset equal current date plus timespan timepicker.
how can current datetimeoffset.now doesn't have time on it, date can add offset it.
thanks
as in datetime
object have date
property, returns date part without time (it means time 00:00:00).
datetime today = datetimeoffset.now.date; datetime result = today + yourtimespan;
with solution lost offset
information (because date
datetime
). keep need subtract time part:
datetimeoffset = datetimeoffset.now; datetimeoffset result = - now.time + yourtimespan;
or constructor:
datetimeoffset = datetimeoffset.now; datetimeoffset result = new datetimeoffset(now.date + yourtimespan, now.offset);
Comments
Post a Comment