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 :
Customer experience | Sales, Customer Insights,...
Suggested Answer

DateTime UTC is different on server than on development environment

(0) ShareShare
ReportReport
Posted on by 40

Im using the dynamics sdk for c# with early bound classes and the scenario is that when an opportunity is created and has certain criteria fulfulled then I send information about the Opportunity to another system.

We have a datetime field called "project start" that should be sent to the external system as UTC date. When I pick this date from a particular opportunity and run code on my development machine I currently get the correct date which means that 3pm in the opportunity is translated to 1pm in UTC date which is correct for my current location and timezone.

However, when I upload this code to the dynamics environment and make the same code execute on the same Opportunity then the date is sent to the external system as "3pm" which results in that the time is shown incorrectly in the external system.

My question is, how can the C# function Datetime.ToUniversalTime return different values when executed on the server compared to from my development machine?

When I do the logging I can see that the datetime format sent to the external system contains the "z" in the end to indicate that it is UTC format...

Help greatly appreciated!

I have the same question (0)
  • Suggested answer
    meelamri Profile Picture
    13,216 User Group Leader on at

    Hi, 

    please refer to this blog: https://mscrm16tech.com/2019/09/07/date-time-issue-due-to-different-timezone-of-user-in-ms-crm/

    Good Luck !

  • Fedorov Profile Picture
    40 on at

    Hi,

    Thanks, the blog made sense and I tried the code which seems to make sense also.

    However I still get the same results with that code that once I upload the plugin to the server the time is off by two hours which I just cannot make sense of...

    I mean, the code from the link check for the date on the server and my dev environment, even though located on my local machine, makes requests against the same environment that I upload the plugin to...so I just think that the results should be the same with this new code but it isn't...

    Any more suggestions would be appreciated.

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 > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 170 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 70

#3
Jimmy Passeti Profile Picture

Jimmy Passeti 50 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans