开发者

How to format the DateTimePicker into hh:mm:ss and What is the appropriate type to save time in mysql?

开发者 https://www.devze.com 2023-03-11 01:06 出处:网络
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开发者_如

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)

0

精彩评论

暂无评论...
验证码 换一张
取 消