Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Milliseconds to System.DateTime

$
0
0

HI

I am trying to convert a millisecond value i get from a calendar event to date time

I get it with an offset of 1hr (earlier than should be)

public static DateTime FromUnixTime(long unixTimeMillis)
{

        var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);

        epoch = TimeZoneInfo.ConvertTimeFromUtc(epoch, TimeZoneInfo.Local);
        return epoch.AddMilliseconds(unixTimeMillis);
    }

Suggestions? How to do this so it gives the correct time?

Regards

M.R.


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>