I have an integer 15791 which represents count of days since epoch and equals 27.03.2013, how can do this convert in C#?
public void method1()
{
  ...
  int days_since_epoch = 15791;
  // how convert `days_since_epoch` to "27.03.2013"
}
Thanks!
I have an integer 15791 which represents count of days since epoch and equals 27.03.2013, how can do this convert in C#?
public void method1()
{
  ...
  int days_since_epoch = 15791;
  // how convert `days_since_epoch` to "27.03.2013"
}
Thanks!
 
    
    Adds a number of days to your epoch.
For example:
var epoch = new DateTime(...);  // Your epoch (01/01/0001 or whatever)
var yourDate = epoch.AddDays(days_since_epoch);
 
    
    Assuming your Epoch date is in a DateTime just use
DateTime epoch = new DateTime(1970,1,1);
int days_since_epoch = 15791;
DateTime converted = epoch.AddDays(days_since_epoch);
 
    
    Simply use the AddDays method, and once you got your final date, format it as usual in the ToString().
 
    
     
    
    Perhaps:
TimeSpan ts = TimeSpan.FromDays(15791);
DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).Add(ts);
 
    
    var date = new DateTime(1970,1,1).AddDays(15791);
Console.WriteLine(date.ToString("dd.MM.yyyy"));
