Reputation: 1158
I have an action that takes in two required DateTime fields, StartDate
and EndDate
. From the API, when I invoke this action those fields are passed as follows:
{
"StartDate":"2018-07-01T00:00:00Z",
"EndDate":"2019-06-30T00:00:00Z"
}
However, when they hit the action I get the following result right as I debug the input parameters:
Start Date - 6/30/2018 6:00 PM | End Date - 6/29/2019 6:00 PM
So the start date has gone from 7/1/2018 midnight to 6/30/2018 6PM and end date has gone from 6/30/2019 midnight to 6/29/2019 6PM. I ensured that our API is passing the correct data and confirmed that there are no additional workflows/actions/plugins that might modify this date.
Why is this date adjusting by 6 hours?
Upvotes: 2
Views: 1114
Reputation: 17562
This is likely to be a time zone conversion. When you intercept date time on the server it has been converted to UTC.
Behavior and format of the date and time attribute.
I imagine your dates are user local (default), which will:
- Stores the date and time value as UTC value in the system.
- The retrieve operation returns the UTC value.
When you retrieve the value programmatically you will need to convert the value back to your local time zone to get the original value you put in, the CRM user interface does this.
You could switch your field to date only or time zone independent if that behaviour better suits your use case. You could do this programmatically if you have a lot of fields to update.
Upvotes: 1