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

Notifications

Announcements

No record found.

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

    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

    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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Siv Sagar Profile Picture

Siv Sagar 93 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 74

#3
Martin Dráb Profile Picture

Martin Dráb 64 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans