monthCalender date format to yyyy-mm-dd : c#

梦想的初衷 提交于 2020-03-04 14:10:51

问题


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.


回答1:


use this:

monthCalendar1.SelectionStart.Date.ToString("yyyy-MM-dd");

DateTime.ToString() accepts custom format as argument



来源:https://stackoverflow.com/questions/19735319/monthcalender-date-format-to-yyyy-mm-dd-c-sharp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!