I have the following code -
DateTime timeStamp; timeStamp = System.Convert.ToDateTime(y.InnerText);
Where y.InnerText is
y.InnerText
I use this step 1. Convert to DateTime. 2. Use ToString(); function
Example :
DateTime myDateTime = DateTime.Now; string myDateTimeString = myDateTime.ToString("yyyy-mm-dd hh:mm:ss");