• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1570
  • Last Modified:

C#.NET VS 2005: Setting the seconds of DATETIMEPICKER value to zero but taking a time and date from the user

C#.NET VS 2005 DateTime obect.  I have a System.Windows.Forms.DateTimePicker component that is getting a start time from the user.  For example, the user choses 9/19/07 at 01:35:PM.  However, what they are getting is 09/19/2007  1:35:13 PM.  The seconds is choosen by the system but I need to get it so that the seconds are set to zero and the rest of the time and date is set as the user wants it.  How does one allow users to set a DateTimePicker object so that the user picks the time, but the seconds are automatically set to 00?
1 Solution
One option is to replace the selected DateTime with a new one that sets the seconds to zero, as:
DateTime selected = new DateTime(yourDateTimePicker.Value.Year,
                                 yourDateTimePicker.Value.Minute, 0);


Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now