monthCalender日期格式为yyyy-mm-dd:C# [英] monthCalender date format to yyyy-mm-dd : c#
本文介绍了monthCalender日期格式为yyyy-mm-dd:C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在MySQL中有一个数据库.现在,我想在数据库中为yyyy-mm-dd格式的data类型的属性插入值.
我将从'monthCalender'获取日期.目前,我正在使用此代码以mm/dd/yyyy格式获取日期.
monthCalendar1.SelectionStart.Date.ToShortDateString()
我应该如何转换格式?
我也觉得MySQL要求这种格式很奇怪.所以我可能是错的.顺便说一下,我在数据库中使用XAMPP.
解决方案
使用此:
monthCalendar1.SelectionStart.Date.ToString("yyyy-MM-dd");
DateTime.ToString()接受自定义格式作为参数>
I have a database in MySQL. Now i want to insert value for a attribute of type data in in the database which is of the format yyyy-mm-dd.
I will be getting date from 'monthCalender'. Currently i am getting the date in format mm/dd/yyyy by using this code.
monthCalendar1.SelectionStart.Date.ToShortDateString()
How should i convert the format?
also i feel its weird for MySQL to ask for such a format. So i may be wrong. by the way am using XAMPP for the database.
解决方案
use this:
monthCalendar1.SelectionStart.Date.ToString("yyyy-MM-dd");
DateTime.ToString() accepts custom format as argument
这篇关于monthCalender日期格式为yyyy-mm-dd:C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文