How To Convert Epoch Time To DateTime In C#
Good morning awesome programmers, Me and my fellow teammate encountered a scenario to convert epoch time to datetime. The solution can be found in stack overflow. private void Form1_Load( object sender, EventArgs e) { //long tms = 1308139229; long tms = 1308143650; DateTime dt = FromUnixTime(tms); MessageBox.Show(dt.ToShortDateString()); } public DateTime FromUnixTime( long unixTime) { var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); return epoch.AddSeconds(unixTime); }