I have the following xml file:
<Test>
    <Header>
       <Title>Test</Title>
       <Time>Wed Mar 21 14:37:04 2018</Time>
...
I can parse it and get the time:
public DateTime Time
{
    get { return _time; }
    private set { _time = value; }
}
foreach (XElement el in header.Elements()) {
    if (String.Compare(el.Name.ToString(), "Time", true) == 0) {
        string format = el.Value;
        _time = DateTime.ParseExact(format, "ddd MMM d H:m:s yyyy", CultureInfo.InvariantCulture);
        Console.WriteLine(_time);
    }
}
With the above solution, I can get the time but in the following format :
3/21/2018 2:56:40 PM
How can I get it in this format?
2018-03-21 14:56:40
Thanks in advance!
 
     
     
    