How to send DateTime variables in session time over a REST service?

0
We have an app with a REST service so we can send our data out and some of the data we send are DateTime variables. When Mendix converts those to JSON in an export mapping, it always uses the UTC time that it stores the dates as and not the session time, which is what we want. Actually, we would like to always send the DateTimes out according to a fixed time zone, but almost every user will already be in that time zone already. How do we make Mendix send out the session time instead of the UTC offset? I tried making a microflow to convert the DateTime to a string that had the Date in session time and then convert that back to a DateTime, but it still sends the UTC offset.
asked
1 answers
0

Hi Eric,

One possible solution is to use a string attribute to send the datetime via Rest.

In other words opt not to send the datetime attribute in your export mapping and instead create a string attribute on the same entity and use that in the export mapping.  To populate the string just parse the datetime using the method you described above, simply don’t convert back to a datetime. 

 

When the attributes are converted to JSON they are essentially all treated as string values anyway, so as long as the format that you parse the DateTime with is compatible with your REST service consumers, it shouldn’t be any different on their end.

 

Hope this helps,

Danny Kumpf

answered