Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,
i have string "07-12-12 09:40AM",it's format "mm-dd-yy",but i need to format for "yy-mm-dd".
how could i do?
Posted

 
Share this answer
 
Comments
Manas Bhardwaj 16-Jul-12 5:55am    
Good links +5!
Prasad_Kulkarni 16-Jul-12 8:29am    
Thank you Manas!
thanks Beyong!
problem had solve, code is
C#
string str = "07-12-12 09:40AM";
IFormatProvider culture = new CultureInfo("en-us", false);
DateTime dt = DateTime.Parse(str, culture);
 
Share this answer
 
C#

private string GetDateResult()
{
string dateString = "07-12-13 09:40AM";
string strResult = "";

DateTime dateResult;
CultureInfo culture = CultureInfo.CreateSpecificCulture("en-US");
DateTimeStyles styles = DateTimeStyles.None;
if (DateTime.TryParse(dateString, culture, styles, out dateResult))
strResult = dateResult.ToString("yy-MM-dd");

return strResult;
}

Use this function pls.Maybe could help you.
 
Share this answer
 

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