Click here to Skip to main content
15,889,281 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I want to change the Datefomat from DD/MM/YYYY to YYYY/MM/DD.
So is there any way to change the date to that format. I am using datepicker to select the date.
I am integrating this datepicker for Windows phone 8 App.
Posted

C#
string myDate = "12-Apr-1976 22:10";
DateTime dateValue = DateTime.Parse(myDate);
string format = "YYYY/MM/DD";
string d = dateValue.ToString(format);
try this
 
Share this answer
 
v3
Comments
Imran Hussain Mozumder 29-Jul-13 6:34am    
I got the solution. But it is for the current date.
But I am selecting the date from DatePicker, so how can I change the format of that date.
If you can help me please send me reply with sample code.
Member 9762654 29-Jul-13 6:55am    
are you using jquery datepicker?
Member 9762654 29-Jul-13 6:58am    
i have improved my solution check that
Imran Hussain Mozumder 29-Jul-13 7:03am    
No, I am using C#
Imran Hussain Mozumder 29-Jul-13 7:12am    
Now this code fulfilled my requirements. Thanx alot.
C#
string strDate = DateTime.Now.ToString("YYYY-MM-DD");
 
Share this answer
 
v2
Comments
Joezer BH 29-Jul-13 8:11am    
5ed
I checked the solution what you guys gave.
It helped me alot, but the actual solution is
string format = "yyyy-MM-dd";
string f = DateTime.Now.ToString(format);
 
Share this answer
 
Comments
Joezer BH 29-Jul-13 8:11am    
5ed
 
Share this answer
 
Comments
Joezer BH 29-Jul-13 8:11am    
5ed

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900