I have a simple buffer like this one:
Byte[] buffer = new byte[] { 0x01, 0x72, 0x60, 0x77, 0x59, 0x80};
And I need to obtain the Date from this value (it's in Unix timeStamp miliseconds)
So I tried to converting to long and then passing to a function I found to convert from long to dateTime like so:
public static DateTime unixTimeStampToDateTime(long unixTimeStamp)
{
// Unix timestamp is seconds past epoch
DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
dtDateTime = dtDateTime.AddSeconds(unixTimeStamp).ToLocalTime();
return dtDateTime;
}
I try to get the long value from the array like this:
long timestamp = BitConverter.ToInt64(buffer,0);
But I get this error:
System.ArgumentException: 'Destination array is not long enough to copy all the items in the collection. Check array index and length. '
What am I missing here? Thanks in advance.
EDIT the expected value out of the convertion is: 05/29/2020 14:45