I have simple quesion but I have no idea how to solve it...
I have this string
RegisterDate = "25-05-2013"; I get this value via input. I want somehow to make this string be
RegisterDate = "2013-05-25"; My question is how could I do it?
Thanks
I have simple quesion but I have no idea how to solve it...
I have this string
RegisterDate = "25-05-2013"; I get this value via input. I want somehow to make this string be
RegisterDate = "2013-05-25"; My question is how could I do it?
Thanks
Try to covert it to real date and convert it back again to string with your desired format.
RegisterDate = "25-5-2013"; DateTime _date = DateTime.ParseExact(RegisterDate, "M-d-yyyy", CultureInfo.InvariantCulture); RegisterDate = _date.ToString("yyyy-MM-dd"); using System.Globalization; in your source file.RegisterDate.There are many ways to do what you want. Here I split the string into the three parts between the dashes, reverse it and then rejoin the parts again:
var registerDate = "25-5-2013"; registerDate = String.Join("-", registerDate.Split('-').Reverse()); If the string represents a date you can also use date parsing and formatting methods. Another option is to use regular expressions.