macca18
macca18

Reputation: 197

C# format string date

I have a string in the following format

19/11/2012 15:40:15

I would like to convert this to UTC format but still keep it as a string. e.g:

2012-11-19T15:40:15.000000+00:00

Upvotes: 1

Views: 76

Answers (1)

Guruprasad J Rao
Guruprasad J Rao

Reputation: 29683

You can use DateTimeOffset.Parse and convert it to UTC and then back to String as below:

string date= "19/11/2012 15:40:15";
string newUTCdate=Convert.ToString(DateTimeOffset.Parse(date).UtcDateTime);

Upvotes: 4

Related Questions