.net - How can I specify the latest time of day with DateTime -


To allow the user to select a date range, the System.DateTime object I am using The user is only able to choose a date (not a time) using a third party calendar, so I will have to specify the time of the day automatically after that date (ie: 00:00:00 or 23:59:59) is selected.

How can I specify the time after the calendar selector has already stored in the form of the date at the time? I can use the AddHours, AddMinutes, AddSeconds methods, but they are relative to the current time that can not be 00:00:00.

start date will need to be 00:00:00 and the time of the 23:59:59 for the entire day of end date Will happen.

If you already have a datetime object and If you want to change the time with 11:59:59 PM, you can use the .date property to get the date along with the set time at 00.00: 00 and after that, Can add minutes and seconds For example:

  var dt = yourDateInstance.Date.AddHours (23) .dimensional (59) .AddSeconds (59);  

If, at the latest, you mean 11:59:59 PM, then it should also work:

  var dt = new dateTime ( Now, era, now month, now, today, 23, 59, 59);  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -