SoFunction
Updated on 2025-03-07

Share examples of time and date operation in c# (c# gets the current date)


private string StampToDate(string timeStamp,string format)
{
DateTime dtStart = (new DateTime(1970, 1, 1));
long lTime = (timeStamp + "0000000");
TimeSpan toNow = new TimeSpan(lTime);
return (toNow).ToString(format);
}

//StampToDate("1394533451","yyyy-MM-dd");
//Result: 2014-3-11