Convertir une date TimeStamp en DateTime en C# et VB.Net
C#
public
static
DateTime ConvertTimeStampToDateTime(
double
unixTimeStamp)
{
// Unix timestamp is seconds past epoch
System.DateTime dtDateTime =
new
DateTime(1970,1,1,0,0,0,0,System.DateTimeKind.Utc);
dtDateTime = dtDateTime.AddSeconds(unixTimeStamp).ToLocalTime();
return
dtDateTime;
}
VB.Net
Public
Shared
Function
ConvertTimeStampToDateTime(
ByVal
unixTimeStamp
As
Double
)
As
DateTime
Dim
dtDateTime
As
System.DateTime =
New
DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc)
dtDateTime = dtDateTime.AddSeconds(unixTimeStamp).ToLocalTime()
Return
dtDateTime
End
Function