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 AX (Archived)

Time zone issue

(0) ShareShare
ReportReport
Posted on by

Hello,


When running DateTimeUtil::getSystemDateTime(), I'm getting the time in GMT rather than EST which is what I have my preferred time zone set to. DateTimeUtil::getUserPreferredTimeZone() is giving me the correct value.

When pulling the time from the AOS using DateTimeUtil::applyTimeZoneOffset(DateTimeUtil::utcNow(), DateTimeUtil::getUserPreferredTimeZone()), I get the time in EST, but I'd prefer to pull the timestamp from the client if possible.

Has anyone ran into this before? My preferred time zone and the company time zone are both set to EST. Is there another setting I'm missing?

Thanks for the help!

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at

    Update: The info log I printed in a test job showed the correct time EST when running DateTimeUtil::applyTimeZoneOffset(DateTimeUtil::utcNow(), DateTimeUtil::getUserPreferredTimeZone()). However using that to set the datetime of a field in a table resulted in offsetting the correct time EST. Meaning, it inserted the datetime of 4 hours in the past.

    It looks like sometimes getSystemDateTime is working, because my older records in that table before the code change all had the correct timestamps. Records in another table that were inserted using getSystemDateTime have the timestamp in GMT. Does anyone know what could cause these inconsistencies?

  • Verified answer
    Abhishek_mishra Profile Picture
    405 on at

    Are you viewing the date field data in sql manager?

  • Community Member Profile Picture
    on at

    This solved it. It's the string conversion that is messing up the time. DateTimeUtil::getSystemDateTime() works when kept as a utcDateTime. The table where it inserted correctly has the field as a TransDateTime. It messes up in the other table because I'm converting it to a string. The DateTime is being used as a default value for that field. This explains why the infolog showed it wrong too.

    Although I can get my code to work now, I'm still curious as to why the string conversion removes the time zone offset if anyone knows.

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 AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans