Convert Unix Time Stamp To System Date Time
Convert Unix Time Stamp To System Date Time
Step 1
Copy the function code below and paste in your page.
public string ConvertToUnixTimeStapToDateTime(double timestamp)
{
// First make a System.DateTime equivalent to the UNIX Epoch.
System.DateTime dateTime = new System.DateTime(1970, 1, 1, 0, 0, 0, 0);
// Add the number of seconds in UNIX timestamp to be converted.
dateTime = dateTime.AddSeconds(timestamp);
// The dateTime now contains the right date/time so to format the string,
// use the standard formatting methods of the DateTime object.
string resDate = dateTime.ToShortDateString() + " " + dateTime.ToShortTimeString();
return resDate;
}
Step 1
Copy the function code below and paste in your page.
public string ConvertToUnixTimeStapToDateTime(double timestamp)
{
// First make a System.DateTime equivalent to the UNIX Epoch.
System.DateTime dateTime = new System.DateTime(1970, 1, 1, 0, 0, 0, 0);
// Add the number of seconds in UNIX timestamp to be converted.
dateTime = dateTime.AddSeconds(timestamp);
// The dateTime now contains the right date/time so to format the string,
// use the standard formatting methods of the DateTime object.
string resDate = dateTime.ToShortDateString() + " " + dateTime.ToShortTimeString();
return resDate;
}
Step 2
Call the function and pass the time span value.
Label1.Text=ConvertToUnixTimeStapToDateTime(128988834);
Happy Programming....With Programming Heaven
Comments
Post a Comment