1

I can't understand in what format cookie.ExpirationTime is. From help articles https://dotnetbrowser.support.teamdev.com/support/solutions/articles/9000110182-working-with-cookiestorage I understood that for set ExpirationTime we need to use this code:

int microsecondsOffset = 1000;
double expires = (DateTime.Now.AddHours(1) - DateTime.MinValue).TotalMilliseconds;
// Cookie will be alive during one hour starting from now
long expirationTimeInMicroseconds = (long)expires * microsecondsOffset;

But when I extract the cookies from cookiesStorage, the cookie.ExpirationTime value is like "13244472757814951", "13244472437311921"... When i convert these values to have date by code:

long expInMillisec = cookie.ExpirationTime / 1000;

TimeSpan span = TimeSpan.FromMilliseconds(expInMillisec);

DateTime date = DateTime.MinValue.Add(span);

I get not valid dates like "13.09.0420 12:12:37". The 420 year...

How can I convert cookie.ExpirationTime to valid DateTime? Please help.

P.S. Also I thought this is UNIX epoch timestamp, but it isn't.

0 Answers0