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

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -