web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Answered

How to use UtcTimeFromLocalTime function in WebAPI?

(0) ShareShare
ReportReport
Posted on by 116

Hi forum!

So we recently found ourselves in need of converting times from user's local time to UTC and other way around in Java script web resource.

To convert time to local time from UTC we used LocalTimeFromUtcTime function in WebAPI like following:


contoso.crm4.dynamics.com/api/data/v9.2/LocalTimeFromUtcTime(TimeZoneCode=@TimeZoneCode,UtcTime=@UtcTime)?@TimeZoneCode=47&@UtcTime=2021-05-05T00:00:00.000Z

and it worked perfectly fine.
But trying to do the opposite conversion we stuck with an issue. The request:
returns the error response:
{
    "error": {
        "code": "0x8006088a",
        "message": "Resource not found for the segment 'UtcTimeFromLocalTime'."
    }
}
Could you please help us with this, is UtcTimeFromLocalTime not supported yet in WebAPI, or we use it in not correct way?
I have the same question (0)
  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: How to use UtcTimeFromLocalTime function in WebAPI?

    Hello,

    Check the description of the function - docs.microsoft.com/.../utctimefromlocaltime - it's described as collection bound (don't ask me, I'm clueless).

    Here is what I was able to compose that bypassed the issue you experienced:

    /api/data/v9.2/resourcegroups/Microsoft.Dynamics.CRM.UtcTimeFromLocalTime(TimeZoneCode=@TimeZoneCode,LocalTime=@LocalTime)?@TimeZoneCode=47&@LocalTime=2021-05-05T00:00:00.000Z

    But my example has issues with datetime format.

  • Andy Kulyk Profile Picture
    116 on at
    RE: How to use UtcTimeFromLocalTime function in WebAPI?

    Ah, I didn't notice that, now I get the format error too. So new challenge: what format does it want?

    But, yeah, the initial question is answered.

    Thank you!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Sahan Hasitha Profile Picture

Sahan Hasitha 284

#2
Sohaib Cheema Profile Picture

Sohaib Cheema 104 User Group Leader

#3
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 77

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans