server time in the calculated attributes

Deborah9 months ago

Hi,
I used to use server time in calculated attributes, I used this function: serverTime.getTime() (return type = number).
I have seen that it does not work now. Does anyone know of an alternative?

Thanks

Anton Tananaev9 months ago

serverTime variable should still be available. Not sure about function call. You might need to enable something to make it available. There's a bunch of configuration parameters related to computed attributes.

Deborah9 months ago

I checked and have all the configurations related to the calculated attributes active.
At one time (can't tell you which version, I was using it 1 year ago.), the call above returned a timestamp value for example: 1692213629474.08
In traccar 5.8 it returns a value "NULL" instead.

By creating an attribute that simply returns serverTime, it returns a string like this: Wed Aug 16 20:36:07 CEST 2023
But that is very difficult to use for doing calculations.

Can you tell if this is an error in the latest versions, or do you know of any alternatives to get this timestamp?

Thanks

Anton Tananaev9 months ago

Most likely it's related to this PR:

https://github.com/traccar/traccar/pull/5036

Deborah9 months ago

Thank you, it looks like I could use it. I'll study on it

Essam5 days ago

Dears,

I need to calculate the duration of trip.
How can get deference of deviceTime and previous record deviceTime (OldDateTime).

Many Thanks in Advance.

Anton Tananaev5 days ago

You can enable processing.computedAttributes.lastAttributes and use lastDeviceTime.

Essam5 days ago

Many Thanks Anton

How can get the deference between deviceTime & lastDeviceTime ?
I tried deviceTime.getTime()-lastDeviceTime.getTime() but no results. The computed attributes dose not return any value.