How to change format date in C#

Now we will learn how to change date format in C#

as we know the format time in mysql is YYYY-MM-DD. but in visual studio the time format if we use datetimepicker is  DD/MM/YYYY.
to change the format date the way is :
1. Add a new textbox , in properties change the name to txtdate.
2.double click in form 1
3. then input the code below
String date;
date= DateTime.Now.ToString(YYYY-MM-DD);
txtdate.Text = date;

4.Debug the program with f5 and see the result

Leave a Reply