Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website

Data source in different timezone


  • Hi

    I am pulling some data points in from a data source that is located on the opposite side of the country, and is in a different timezone (I am in UTC+8 and the data source is in UTC+11), so I am three hours behind the remote site.

    Is there any way to offset the timestamps?

    Thanks
    Jeremy


  • That's an interesting one. All time stamps are stored in the database as Unix time so the time zone wouldn't mater in that sense. You can set a time zone for an individual user in which case the data should be translated into that users time zone. In DGLux you can always use a script to modify the time stamp before it goes on a chart.

    You could also use a Meta Data source to log the data with a time off set. Not sure if any of this helps.

    Joel.


  • Hey Joel,

    I didn't know that users could set timezones, I'll remember that for future use.
    In this particular case though it makes more sense to 'normalise' the point timestamp, just based on the way the data will be used (which is always in the context of the remote timezone) and the way that we use and access Mango.

    You could also use a Meta Data source to log the data with a time off set. Not sure if any of this helps.

    That would work. I already have a Meta Data point that performs some additions so it would be simple to pop in there.
    Could you give me a code hint?

    Thankyou
    Jeremy


  • This is from the help file for the Meta Data Source:

    To explicitly set the timestamp of a value, set the TIMESTAMP context variable before your return statement. The value to which to set this variable must be milliseconds since the epoch (not a native date). For example:

    TIMESTAMP = new Date().getTime();
    return p.value + 1;

    I haven't tied this but I think you could do something like this to subtract an hour of the current time

    TIMESTAMP = (new Date().getTime()) - 3600000;
    

    Keep in mind that Mango doesn't like future dating things to you could have problems if you need to advance the time zone.

    I still think this is not the most ideal solution but should work.

    Joel.