I have a question to ask. I have an app that works as a work attendance clock, and when making the entry or exit, I get the GPS data, these are:
- Latitude
- Length
- Date and time.
The detail I have is that if you change the time of the device I get that time and not the actual time. The question is, how would you get the correct GPS date?
So far I have this:
public void OnLocationChanged(GPS.Location location)
{
if (location != null)
{
longitudval = location.Longitude;
latitudval = location.Latitude;
date= Helpers.HelpMethods.GetLocalDateTime(location.Time);
i++;
if (i == 2)
{
decimal longitude = decimal.Parse(longitudval.ToString());
decimal latitude = decimal.Parse(latitudval.ToString());
catStores = db.GetStores(longitude, latitude);
}
}
}
My method to obtain the date is this:
public static DateTime GetLocalDateTime(long fromGPSMiliseconds)
{
DateTime dateTime = new DateTime();
var startdate = DateTimeOffset.FromUnixTimeMilliseconds(fromGPSMiliseconds);
dateTime = Convert.ToDateTime(startdate.ToLocalTime().ToString());
return dateTime;
}
Thank you very much for your support.