AnsweredAssumed Answered

TimeZone Question

Question asked by ernstamort on Jan 27, 2017
Latest reply on Jan 30, 2017 by ernstamort

Before I give up ....

 

I have a tool that converts a string datetime to a AFAttribue of type datetype. Here is the code:

        private DateTime ConvertTimezones(string dateTimeString)

        {

            CultureInfo provider = CultureInfo.InvariantCulture;

            var dateTime = DateTime.ParseExact(dateTimeString, DateTimeFormat, provider);

            var sourceUTC = TimeZoneInfo.ConvertTimeToUtc(dateTime, SourceTimeZone);

            var sourceLocal = sourceUTC.ToLocalTime();

            return sourceLocal;

        }

 

The idea is that you specify a string, a string format and the timezone and it will sends the datetime to PI.

11:00:00 AM EST will be send as 11:0:00 to the server in EST

11:0:00 AM PST will be send as 2:00:00 PM to the server in EST

 

All this is one the dev server, so client and server are all on EST.

In PI System builder the attribute is displayed correctly. In DataLink the value is always 2 PM for some reason.

Also the value doesn't change if I change the timezone to server, client, UTC ...

 

Any ideas?

Outcomes