DateTime Helper
Applies To: Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012
In Microsoft Dynamics AX you can set the preferred time zone. To get the date/time value that considers the preferred time zone, use the AxDateTimeHelper class. This class is part of the Microsoft.Dynamics.Framework.Portal.UI namespace. You will use the Session Object when you retrieve the value.
For example, the following code for a button in a User Control retrieves the current date and time. The local time and the UTC time are derived from this value and displayed in text boxes in the User Control.
protected void WhatTimeIsIt_Click(object sender, EventArgs e)
{
DateTime dt = AxDateTimeHelper.GetUserNow(AxSession);
LocalTime.Text = dt.ToString();
UTCTime.Text = dt.ToUniversalTime().ToString();
}