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

How to get the system time zone from code

(0) ShareShare
ReportReport
Posted on by

Hello,

is there way to get the "+01:00" from defined timezone?

For example, the setup is:

(GMT+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna

But I need to have only +01:00.

Is there any standard method for it?

Thanks.

I have the same question (0)
  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: How to get the system time zone from code

    What would you use it for? Could you describe your business requirement?

    Or do you mean the user's timezone? You can get it by DateTimeUtil::getUserPreferredTimeZone().

  • Suggested answer
    vinitgoyal2005 Profile Picture
    6,332 on at
    RE: How to get the system time zone from code

    Hi,

    As mentioned by Nikolas, not sure what is your requirement but you can check this document for any of the date related functionality: docs.microsoft.com/.../gg837448(v=ax.60)

  • DAX Dev Profile Picture
    on at
    RE: How to get the system time zone from code

    Client request this format in one of the generated xml files (Customization).

  • nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: How to get the system time zone from code

    As far as I understand, your question isn't related to getting the system time zone via code.

    Could you share more details. Is it about the format of a date/time field? Or some timezone field?

    How is the XML created? Via Data management? Or your custom code?

    Please share the XML that the system produces now, as well as description how you would like it to appear. And any custom code that you have related to this process.

  • Deepak Agarwal Profile Picture
    8,585 on at
    RE: How to get the system time zone from code

    Hello,

    There is no standard method for this. You need to build your logic something like, convert time in str and use substring method get last 6 characters.

    Give a try and let me know if you need any further help there.

  • WillWU Profile Picture
    22,361 on at
    RE: How to get the system time zone from code

    Hi DAX Dev,

    As Nikolaos said, please share your XML file.

    And if you just want to add one hour to the time, you could use

    transDateTime = DateTimeUtil::addHours(transDateTime, 1);

    Hope this helps.

  • Suggested answer
    Sukrut Parab Profile Picture
    71,699 Moderator on at
    RE: How to get the system time zone from code

    Hi DAX_Dev ,

    I agree with Deepak. You need to get timezone using dateTimeUtil class and then use your own logic  by converting that value in a string format and using string function to get the desire output. Whatever you are using to generate your xml may be its  your own  class, external library or data entity  you have to write your own logic.

  • Suggested answer
    Martin Dráb Profile Picture
    236,495 Most Valuable Professional on at
    RE: How to get the system time zone from code

    You can use .NET string formatting functions with '%K' format specifier. Like this:

    System.DateTime datetime = ...;
    str tzOffset = System.String::Format('{0:%K}', datetime);

    It'll display the timezone used by the DateTime value - make sure that the value is in the timezone you want (apply the timezone if it isn't).

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