web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
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,166 Moderator on at

    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

    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

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

  • nmaenpaa Profile Picture
    101,166 Moderator on at

    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,648 on at

    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,363 on at

    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,735 Moderator on at

    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
    239,082 Most Valuable Professional on at

    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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 653

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 493 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 317 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans