I have a date in XML:
<time>1340517600</time>
How can I convert it to a DateTime in C#?
I have a date in XML:
<time>1340517600</time>
How can I convert it to a DateTime in C#?
 
    
     
    
    That's a Unix timestamp for "Sun, 24 Jun 2012 06:00:00 GMT".
To convert from a Unix timestamp to a .NET DateTime, look at these questions:
Here is Jon Skeet's solution:
private static readonly DateTime Epoch = new DateTime(1970, 1, 1, 0, 0, 0, 
                                                      DateTimeKind.Utc);
public static DateTime UnixTimeToDateTime(string text)
{
    double seconds = double.Parse(text, CultureInfo.InvariantCulture);
    return Epoch.AddSeconds(seconds);
}
See it working online: ideone
 
    
    