Please provide some examples from logs.
Is this what you need?
2024-09-25 19:13:44 INFO: [T9d35d19d: watch > 80.62.116.109] [SG*9058976644*0002*LK]
2024-09-25 19:13:46 INFO: [T9d35d19d: watch < 80.62.116.109] [SG*9058976644*0084*UD,250924,191343,A,57.031646,N,9.941275,E,0.00,0,0,18,96,39,0,50,00000000,4,1,238,01,661,30,96,661,8105,96,661,33,96,661,8095,96,,00]
2024-09-25 19:13:46 INFO: [T9d35d19d] id: 9058976644, time: 2024-09-25 19:13:43, lat: 57.03165, lon: 9.94128, course: 0.0
2024-09-25 19:13:51 INFO: [T9d35d19d: watch < 80.62.116.109] [SG*9058976644*0084*UD,250924,191348,A,57.031646,N,9.941276,E,0.00,0,0,18,96,39,0,50,00000000,4,1,238,01,661,30,96,661,8105,96,661,33,96,661,8095,96,,00]
2024-09-25 19:13:51 INFO: [T9d35d19d] id: 9058976644, time: 2024-09-25 19:13:48, lat: 57.03165, lon: 9.94128, course: 0.0
2024-09-25 19:14:21 INFO: [T9d35d19d: watch < 80.62.116.109] [SG*9058976644*0084*UD,250924,191418,A,57.031646,N,9.941278,E,0.00,0,0,19,96,39,0,50,00000000,4,1,238,01,661,30,96,661,8105,96,661,33,96,661,8095,96,,00]
2024-09-25 19:14:21 INFO: [T9d35d19d] id: 9058976644, time: 2024-09-25 19:14:18, lat: 57.03165, lon: 9.94128, course: 0.0
2024-09-25 19:14:51 INFO: [T9d35d19d: watch < 80.62.116.109] [SG*9058976644*0084*UD,250924,191448,A,57.031645,N,9.941278,E,0.00,0,0,19,96,39,0,50,00000000,4,1,238,01,661,30,96,661,8105,96,661,33,96,661,8095,96,,00]
2024-09-25 19:14:51 INFO: [T9d35d19d] id: 9058976644, time: 2024-09-25 19:14:48, lat: 57.03165, lon: 9.94128, course: 0.0
2024-09-25 19:15:22 INFO: [T9d35d19d: watch < 80.62.116.109] [SG*9058976644*0084*UD,250924,191518,A,57.031648,N,9.941278,E,0.00,0,0,20,96,39,0,50,00000000,4,1,238,01,661,30,96,661,8105,96,661,33,96,661,8095,96,,00]
2024-09-25 19:15:22 INFO: [T9d35d19d] id: 9058976644, time: 2024-09-25 19:15:18, lat: 57.03165, lon: 9.94128, course: 0.0
I see that the time is correct here. I guess we need the sample that wasn't correct, right?
So here's a log from another device, which was set at GMT+2. The time is correct when watching the device in Traccar - even if the device isn't set to UTC.
When polling the API the device time is 2 hours behind regardless if the device time is GMT +2 or is its UTC. Basically the API reports the same device time regardless if the device is set to UTC or GMT +2. I would have expected the device time to be correct when the device is set to the actual time (GMT +2). OR I would have expected the device running UTC would have reflected a +2 hour in the time part, when the server time is set to GMT +2.
2024-09-27 13:05:15 INFO: [T1ad43420] id: 9058976548, time: 2024-09-27 13:05:11, lat: 57.03155, lon: 9.94070, course: 326.0
2024-09-27 13:05:40 INFO: [T1ad43420: watch < 87.49.146.58] [SG*9058976548*0086*UD,270924,130537,A,57.031550,N,9.940731,E,0.00,326,0,15,83,96,0,50,00000000,4,1,238,01,661,30,83,661,8095,83,661,2434,83,661,33,83,,00]
2024-09-27 13:05:40 INFO: [T1ad43420] id: 9058976548, time: 2024-09-27 13:05:37, lat: 57.03155, lon: 9.94073, course: 326.0
2024-09-27 13:06:11 INFO: [T1ad43420: watch < 87.49.146.58] [SG*9058976548*0086*UD,270924,130607,A,57.031541,N,9.940776,E,0.00,326,0,14,83,96,0,50,00000000,4,1,238,01,661,30,83,661,8095,83,661,2434,83,661,33,83,,00]
I see that the device time matches server time, so this is not where the issue is. What do you get from the API exactly?
btw what did you mean exactly when you said "traccar server is set to GMT +2"?
But should the device time match the server time when the device is set to GMT +2 and not UTC?
Perhaps a poorly choice of words, I mean the traccar application under server setting and then timezone (Not the actual VPS, that is running UTC)
This is the output from the API
{
"id": 624,
"attributes": {
"sat": 14,
"rssi": 83,
"batteryLevel": 96,
"steps": 0,
"distance": 2.90426743927984,
"totalDistance": 29694.9951166765,
"motion": false
},
"deviceId": 2,
"protocol": "watch",
"serverTime": "2024-09-27T13:06:11.000+00:00",
"deviceTime": "2024-09-27T13:06:07.000+00:00",
"fixTime": "2024-09-27T13:06:07.000+00:00",
"outdated": false,
"valid": true,
"latitude": 57.031541,
"longitude": 9.940776,
"altitude": 0,
"speed": 0,
"course": 326,
"address": null,
"accuracy": 0,
"network": {
"radioType": "gsm",
"considerIp": false,
"cellTowers": [
{
"cellId": 30,
"locationAreaCode": 661,
"mobileCountryCode": 238,
"mobileNetworkCode": 1,
"signalStrength": -83
},
{
"cellId": 8095,
"locationAreaCode": 661,
"mobileCountryCode": 238,
"mobileNetworkCode": 1,
"signalStrength": -83
},
{
"cellId": 2434,
"locationAreaCode": 661,
"mobileCountryCode": 238,
"mobileNetworkCode": 1,
"signalStrength": -83
},
{
"cellId": 33,
"locationAreaCode": 661,
"mobileCountryCode": 238,
"mobileNetworkCode": 1,
"signalStrength": -83
}
]
},
"geofenceIds": null
}
But should the device time match the server time when the device is set to GMT +2 and not UTC?
That depends. You device might be reporting timezone as well, in which case it doesn't matter what you set, it will always be decoded correctly. Anyway, the point is that it's decoded correctly, so you're looking in the wrong place.
The output from the API looks correct. Server time again matches device time, which indicates that everything is working correctly.
Then why doesn't the API reflect the timezone in the last part of the time element?
Because that's just how it works. Not sure why it matters what timezone is in there. It's a time with timezone and any time library will handle it correctly as is.
To me it just makes no sense at all when the user has set a time zone, and that particular user is polling the API, it completely ignores the time zone and reports the local device time rather than the localised time based on the timezone. That's how the application works, which does make a lot of sense.
Timezone only makes sense for display purposes. What is passed in the API doesn't matter because it should never be displayed as is to the end user. And as I said, any programming library will handle this value correctly.
The VPS server time is set to GMT UTC.
The device is set to GMT UTC.
The traccar server is set to GMT +2
In Traccer the device time is reported correctly and matches the local time.
When using the API both deviceTime and serverTime are GMT UTC and as such show time hours behind. I also tried to adjust the device time to GMT +2 but that didn't help. Actually nothing I've adjust has made the deviceTime and serverTime not showing different times.
Surely I'm overlooking something, but I can figure out what it is.