How to format the DateTimePicker into hh:mm:ss and What is the appropriate type to save time in mysql?
I want to save the time in the format hh:mm:ss from the DateTimePicker to MySQL database, How to format the DateTimePicker into hh:mm:ss only without date and What is the appropriate type to s开发者_如何学编程ave time in mysql?
Regards & Thanks,
Putri Diana
You can format it to show time by
dateTimePicker1.Format = DateTimePickerFormat.Custom;
dateTimePicker1.CustomFormat = "hh:mm:ss";
dateTimePicker1.ShowUpDown = true;
Get the value into a Timespan object in this way for processing in your code
TimeSpan ts1 = TimeSpan.Parse(dateTimePicker1.Text);
I think MySql has got a Time Datatype you could use that (Ahh Got this here)
精彩评论