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)

DateTimeUtil::utcNow returning date from another timezone.

(0) ShareShare
ReportReport
Posted on by 3,013

DateTimeUtil::utcNow. According to the MSDN: "This method is run on the server, so that the time that is returned is the system time of the server"

However, If I create a method with this code:

private void TimeTest()
{
    str MyDate;
    ;
    MyDate= DateTimeUtil::toStr(DateTimeUtil::utcNow());
    Box::info(MyDate);
}


It returns the time from another TImezone. I've checked my user's timezone in AX and also the AOS Server timezone, and both have London timezone. When server time is 11:00, it returns 10:00

utc.png

Any ideas on what can be causing this behaviour?

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    237,970 Most Valuable Professional on at

    As the name suggests, utcNow() returns in time in UTC (Coordinated Universal Time), not in any local timezone. What the documentation talks about is what's the source; it doesn't mean that utcNow() doesn't return UTC.

    You can apply a time zone by DateTimeUtil::applyTimeZoneOffset(), if you want a local time instead of UTC.

  • Suggested answer
    Community Member Profile Picture
    on at

    Like Martin suggests, you're looking at the wrong method call:

    here are some options for you to use:

    today();                              // print system date on AOS where the code is executed

    systemDateGet();               // print the AX session date.

    To see the difference, you will need to change the session date of AX (Tools --> Session date on the client)

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