{
  "id": 239187,
  "title": "Time conversion: UTC -> GPS",
  "url": "/competitions/google-smartphone-decimeter-challenge/discussion/239187",
  "author_name": "",
  "post_date": "2021-05-15T06:59:09.201627600Z",
  "votes": 50,
  "comment_count": 5,
  "views": 0,
  "content": "<p>In this competition our time is <code>millisSinceGpsEpoch</code>, whilst the raw data time is in <code>utcTimeMillis</code>.</p>\n<p>The UTC time used is the <a href=\"https://en.wikipedia.org/wiki/Unix_time\" target=\"_blank\">Unix time</a>, which started on the 1 January 1970, meanwhile GPS time started on the 6 January 1980.  So, to convert from UTC to GPS:</p>\n<blockquote>\n  <p><code>GPS(ms) = UTC(ms) - 315964800000</code></p>\n</blockquote>\n<p>However, nothing is ever that easy, and we will have to watch out for the <a href=\"https://en.wikipedia.org/wiki/Leap_second\" target=\"_blank\">leap seconds</a>, as each satellite navigation system treats them in their own way; some take them into account, others do not, and it seems that our phones frequently switch between satellite constellations (<code>ConstellationType</code>).</p>\n<p>See also: <a href=\"https://www.andrews.edu/~tzs/timeconv/timealgorithm.html\" target=\"_blank\">GPS Time Conversion Algorithm</a> (PHP code from LIGO)</p>\n<p>All the best,<br>\ncarl</p>",
  "messages": [
    {
      "id": "1308393",
      "postDate": "05/15/2021 06:59:09",
      "content": "<p>In this competition our time is <code>millisSinceGpsEpoch</code>, whilst the raw data time is in <code>utcTimeMillis</code>.</p>\n<p>The UTC time used is the <a href=\"https://en.wikipedia.org/wiki/Unix_time\" target=\"_blank\">Unix time</a>, which started on the 1 January 1970, meanwhile GPS time started on the 6 January 1980.  So, to convert from UTC to GPS:</p>\n<blockquote>\n  <p><code>GPS(ms) = UTC(ms) - 315964800000</code></p>\n</blockquote>\n<p>However, nothing is ever that easy, and we will have to watch out for the <a href=\"https://en.wikipedia.org/wiki/Leap_second\" target=\"_blank\">leap seconds</a>, as each satellite navigation system treats them in their own way; some take them into account, others do not, and it seems that our phones frequently switch between satellite constellations (<code>ConstellationType</code>).</p>\n<p>See also: <a href=\"https://www.andrews.edu/~tzs/timeconv/timealgorithm.html\" target=\"_blank\">GPS Time Conversion Algorithm</a> (PHP code from LIGO)</p>\n<p>All the best,<br>\ncarl</p>",
      "rawMarkdown": "In this competition our time is `millisSinceGpsEpoch`, whilst the raw data time is in `utcTimeMillis`.\n\nThe UTC time used is the [Unix time](https://en.wikipedia.org/wiki/Unix_time), which started on the 1 January 1970, meanwhile GPS time started on the 6 January 1980.  So, to convert from UTC to GPS:\n\n> `GPS(ms) = UTC(ms) - 315964800000`\n\nHowever, nothing is ever that easy, and we will have to watch out for the [leap seconds](https://en.wikipedia.org/wiki/Leap_second), as each satellite navigation system treats them in their own way; some take them into account, others do not, and it seems that our phones frequently switch between satellite constellations (`ConstellationType`).\n\nSee also: [GPS Time Conversion Algorithm](https://www.andrews.edu/~tzs/timeconv/timealgorithm.html) (PHP code from LIGO)\n\nAll the best,\ncarl",
      "votes": null
    },
    {
      "id": "1327595",
      "postDate": "05/29/2021 12:52:51",
      "content": "<p>Hello, <a href=\"https://www.kaggle.com/carlmcbrideellis\" target=\"_blank\">@carlmcbrideellis</a> !<br>\nThanks a lot! This was helpfull</p>\n<p>Just to add some info to your post:<br>\nLeap seconds is 18 or 19 based on sattelite (so add 18000 or 19000 to formula)</p>\n<p>But basically logs data seems to match gt_csv from the start, so if someone just need merging to baseline, this should works for pair collection-phone:</p>\n<p><code>(GPS_time_column - start_Baseline_time + 500) // 1000</code></p>\n<p>And then aggregate and merge from start</p>",
      "rawMarkdown": "Hello, @carlmcbrideellis !\nThanks a lot! This was helpfull\n\nJust to add some info to your post:\nLeap seconds is 18 or 19 based on sattelite (so add 18000 or 19000 to formula)\n\nBut basically logs data seems to match gt_csv from the start, so if someone just need merging to baseline, this should works for pair collection-phone:\n\n`(GPS_time_column - start_Baseline_time + 500) // 1000`\n\nAnd then aggregate and merge from start",
      "votes": null
    },
    {
      "id": "1336645",
      "postDate": "06/05/2021 05:34:32",
      "content": "<p><a href=\"https://www.kaggle.com/sivtsovdanil\" target=\"_blank\">@sivtsovdanil</a> shouldn't we just use 18, as the leap seconds figure hasn't changed since 2016? (ref.  <a href=\"https://endruntechnologies.com/support/leap-seconds\" target=\"_blank\">https://endruntechnologies.com/support/leap-seconds</a>) </p>",
      "rawMarkdown": "sivtsovdanil shouldn't we just use 18, as the leap seconds figure hasn't changed since 2016? (ref.  https://endruntechnologies.com/support/leap-seconds)",
      "votes": null
    },
    {
      "id": "1338561",
      "postDate": "06/06/2021 14:47:32",
      "content": "<p>Hello, <a href=\"https://www.kaggle.com/jh8102\" target=\"_blank\">@jh8102</a> !</p>\n<p>I also found number 18 when tried to search. <br>\nBut then I tried to merge data on time columns and find out that GPS and UTC time columns ranges are equal, but for some ranges bias is 18 and for other 19. </p>\n<p>It can also be due to shift in data collection start/end. I will try to check it later, but now I believe it is due to different leap seconds</p>",
      "rawMarkdown": "Hello, @jh8102 !\n\nI also found number 18 when tried to search. \nBut then I tried to merge data on time columns and find out that GPS and UTC time columns ranges are equal, but for some ranges bias is 18 and for other 19. \n\nIt can also be due to shift in data collection start/end. I will try to check it later, but now I believe it is due to different leap seconds",
      "votes": null
    },
    {
      "id": "1374143",
      "postDate": "07/03/2021 04:09:22",
      "content": "<p>thank you your advice. I cound't converted. very helpfull.</p>",
      "rawMarkdown": "thank you your advice. I cound't converted. very helpfull.",
      "votes": null
    },
    {
      "id": "1401346",
      "postDate": "07/27/2021 08:39:46",
      "content": "<p>Thank you! I've been looking for for a long time</p>",
      "rawMarkdown": "Thank you! I've been looking for for a long time",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1327595,
      "author_name": "sivtsovdanil",
      "author_url": "",
      "post_date": "05/29/2021 12:52:51",
      "content": "<p>Hello, <a href=\"https://www.kaggle.com/carlmcbrideellis\" target=\"_blank\">@carlmcbrideellis</a> !<br>\nThanks a lot! This was helpfull</p>\n<p>Just to add some info to your post:<br>\nLeap seconds is 18 or 19 based on sattelite (so add 18000 or 19000 to formula)</p>\n<p>But basically logs data seems to match gt_csv from the start, so if someone just need merging to baseline, this should works for pair collection-phone:</p>\n<p><code>(GPS_time_column - start_Baseline_time + 500) // 1000</code></p>\n<p>And then aggregate and merge from start</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 1336645,
      "author_name": "jh8102",
      "author_url": "",
      "post_date": "06/05/2021 05:34:32",
      "content": "<p><a href=\"https://www.kaggle.com/sivtsovdanil\" target=\"_blank\">@sivtsovdanil</a> shouldn't we just use 18, as the leap seconds figure hasn't changed since 2016? (ref.  <a href=\"https://endruntechnologies.com/support/leap-seconds\" target=\"_blank\">https://endruntechnologies.com/support/leap-seconds</a>) </p>",
      "votes": null,
      "replies": [
        {
          "id": 1338561,
          "author_name": "sivtsovdanil",
          "author_url": "",
          "post_date": "06/06/2021 14:47:32",
          "content": "<p>Hello, <a href=\"https://www.kaggle.com/jh8102\" target=\"_blank\">@jh8102</a> !</p>\n<p>I also found number 18 when tried to search. <br>\nBut then I tried to merge data on time columns and find out that GPS and UTC time columns ranges are equal, but for some ranges bias is 18 and for other 19. </p>\n<p>It can also be due to shift in data collection start/end. I will try to check it later, but now I believe it is due to different leap seconds</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1374143,
      "author_name": "tensorchoko",
      "author_url": "",
      "post_date": "07/03/2021 04:09:22",
      "content": "<p>thank you your advice. I cound't converted. very helpfull.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 1401346,
      "author_name": "taiyofuckyou",
      "author_url": "",
      "post_date": "07/27/2021 08:39:46",
      "content": "<p>Thank you! I've been looking for for a long time</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "1308393": "In this competition our time is `millisSinceGpsEpoch`, whilst the raw data time is in `utcTimeMillis`.\n\nThe UTC time used is the [Unix time](https://en.wikipedia.org/wiki/Unix_time), which started on the 1 January 1970, meanwhile GPS time started on the 6 January 1980.  So, to convert from UTC to GPS:\n\n> `GPS(ms) = UTC(ms) - 315964800000`\n\nHowever, nothing is ever that easy, and we will have to watch out for the [leap seconds](https://en.wikipedia.org/wiki/Leap_second), as each satellite navigation system treats them in their own way; some take them into account, others do not, and it seems that our phones frequently switch between satellite constellations (`ConstellationType`).\n\nSee also: [GPS Time Conversion Algorithm](https://www.andrews.edu/~tzs/timeconv/timealgorithm.html) (PHP code from LIGO)\n\nAll the best,\ncarl",
    "1327595": "Hello, @carlmcbrideellis !\nThanks a lot! This was helpfull\n\nJust to add some info to your post:\nLeap seconds is 18 or 19 based on sattelite (so add 18000 or 19000 to formula)\n\nBut basically logs data seems to match gt_csv from the start, so if someone just need merging to baseline, this should works for pair collection-phone:\n\n`(GPS_time_column - start_Baseline_time + 500) // 1000`\n\nAnd then aggregate and merge from start",
    "1336645": "sivtsovdanil shouldn't we just use 18, as the leap seconds figure hasn't changed since 2016? (ref.  https://endruntechnologies.com/support/leap-seconds)",
    "1338561": "Hello, @jh8102 !\n\nI also found number 18 when tried to search. \nBut then I tried to merge data on time columns and find out that GPS and UTC time columns ranges are equal, but for some ranges bias is 18 and for other 19. \n\nIt can also be due to shift in data collection start/end. I will try to check it later, but now I believe it is due to different leap seconds",
    "1374143": "thank you your advice. I cound't converted. very helpfull.",
    "1401346": "Thank you! I've been looking for for a long time"
  },
  "source": "meta"
}