Reputation: 3965
I need to convert the following:
"2015-09-18T19:00:00"
to
"2015/09/18/1900"
I'm able to do this a hacky way by converting the top one to a datetime and then extracting the year,month,day,hour and building the bottom string. Is there a cleaner way to do this?
Upvotes: 1
Views: 56
Reputation: 69
string date = "2015-09-18T19:00:00";
string d= Convert.ToDateTime(date).ToString("yyyy/MM/dd/HHmm");
Upvotes: 1
Reputation: 1564
You can do the following:
var result = DateTime.Parse("2015-09-18T19:00:00").ToString("yyyy/MM/dd/HHmm")
Upvotes: 3