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 - Unusual behaviour when drawing lots of images onto a large canvas -

how can i manage url using .htaccess in php? -

javascript - Chart.js - setting tooltip z-index -