Wednesday, June 21, 2006

Convert datetime string in one format to another in .NET.

Objective: Given a string in UTC format, convert it to a easily readable format

Solution:
string input = "2006-06-14T17:15:55.197-07:00";
string output = Convert.ToDateTime(input).ToString("f");

Assuming the culture is en-US, the variable "output" will be set to the value "Wednesday, June 14, 2006 5:15 PM".

References:
.NET Framework Developer's Guide

No comments:

What is success?

The journey of life takes us through varied experiences like landing an admission at a prestigious college, earning a degree, getting hired,...