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 :
Finance | Project Operations, Human Resources, ...
Suggested answer

get User time instead of system time

(0) ShareShare
ReportReport
Posted on by 206

Hi .

I am facing an issue in which my dev box run at australian time zone and I am testing the code from indian time zone , so the requirement is such that we need to get the user time zone instead of getting system time zone .... I know I can get system date time by using getSystemDateTime() .but how to get the local current time zone in with the user is testing .In simple words I want to get windows time whatever is there .

8255.pastedimage1621587010432v1.png

I have the same question (0)
  • nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: get User time instead of system time

    Hi Nishi,

    is this question about Dynamics AX 2012 (you posted on AX forum) or D365 F&O?

    In most cases you don't need to care about the system (server) timezone at all.

    First of all, all timestamps from user transactions are stored as UTC time in the database. 

    Second, every user defines their time zone in the Dynamics user setup. This setting determines how the UTC timestamps from the database are displayed to the user. And how user's datetime inputs are converted to UTC before storing to database. You can also change the time zone there if you want to test as if you were on a different time zone.

    If you need any more help, please let us know what Dynamics product you're talking about, and also please describe all details that you can about your actual test case, and functional requirement. Thanks!

  • Martin Dráb Profile Picture
    236,495 Most Valuable Professional on at
    RE: get User time instead of system time

    Which version of AX is it about?

    In general, the time on the local machine isn't relevant. What counts are two things: system time and user's timezone. If user's timezone is the same as timezone on the local machine, you'll get the local time. But users will get time in their timezone even if a wrong timezone is set up in Windows.

    You can also easily test various timezones by changes user settings, completely ignoring what timezone is configured in Windows.

  • Nishi Gupta Profile Picture
    206 on at
    RE: get User time instead of system time

    D365Fo .The requirement is that we need to do a naming convention for reports in which timestamp needs to be added on the name of the report .for Ex. SalesInvoice_20210521141900 (taking reference of above image) . but when we run the report we get the timestamp of the system. This is creating confusion for the user as he is not getting the right time at which he is generating the report.

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: get User time instead of system time

    Moved to D365 Finance forum.

    You can use UserInfo.PreferredTimeZone field to find out user's timezone. And then you can convert the UTC timestamp to local time for that timezone.

    However please take into account that if you don't put absolute (UTC) timestamp in the filename, then the files will not be sorted correctly (chronologically), and the names can even be confusing if users from many time zones are creating them.

  • Suggested answer
    Nishi Gupta Profile Picture
    206 on at
    RE: get User time instead of system time

    the legal entity didnt have the correct timezone set , which led to all these problems .

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 1,933

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 793 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 537 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans