How can I set a datetime value for form data in code-behind with the consideration of user time zone and Daylight Saving time?


WorkflowGen will automatically take the date value entered by user from a DateTime text field on a web form and add the proper value to the FormData. However, if a date is set manually in code-behind, by default the date will not have the time zone factor and it will cause a date issue.

For example, May 1, 2019 (2019-05-01) will become 2019-05-01T00:00:00 in the WorkflowGen form data. When this value is passed to WorkflowGen process data, if the time zone is Eastern US & Canada time, it will become April 30, 2019 because of the 4-hour delay.


Use the WorkflowGen.My DLL class method to format your datetime in consideration of the user’s current time zone. Assuming the current time zone is Eastern US Canada (Daylight Saving time) and the datetime value myDateTime is 2019-05-01. It can be processed to transform myDateTime to myUtcDateTime.

DateTime myUtcDateTime = (new WorkflowGen.My.Globalization.TimeZoneInformation(this.CurrentTimeZoneInfo)).ToUtcTime(myDateTime);

WorkflowGen.My has the Globalization.TimeZoneInformation class, and CurrentTimeZoneInfo is part of the WorkflowGenPage that contains the current user time zone info.

After the transformation, myUtcDateTime will contain the value 2019-05-01T04:00:00 and WorkflowGen will be able to translate it properly for process data. The T04:00:00 means -5 hours Eastern time zone +1 hour for Daylight Saving time

Note: You must be using WorkflowGen v5.1.8 or later and WorkflowGen.My DLL v.2.2.0 or later in your web form.