2 Replies Latest reply on Jan 30, 2017 2:34 PM by ernstamort

    TimeZone Question


      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?