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, ...
Unanswered

How to convert string to UTCDateTime?

(0) ShareShare
ReportReport
Posted on by 1,552

Hi,

I have the following:

str dateString = "Sunday, 21 Feb 2010 19:05:15 GMT"

how can i convert this to UTCDateTime?

I have the same question (0)
  • AdnDalhi Profile Picture
    336 on at
    RE: How to convert string to UTCDateTime?

    Hi junior AX,

    Please refere to this 2 links, you will find your answer:

    String format options for UtcDateTime:

    dev.goshoom.net/.../

    Working with utcDateTime Functionality in Dynamics AX 2012 :

    stoneridgesoftware.com/.../

  • HenryXie Profile Picture
    on at
    RE: How to convert string to UTCDateTime?

    Hi

    Dynamics AX 2012 utilizes the utcDateTime data type to store date time information in the database using the Greenwich Mean Time definition of time. This allows the data to be date stamped in a manner that does not reflect the client or AOS time zone (this date/time stamp is considered to be time zone agnostic).

    DateTimeUntil class: https://docs.microsoft.com/en-us/previous-versions/dynamics/ax-2012/system-classes/gg837448(v=ax.60)?redirectedfrom=MSDN

    static void DateConvert(Args _args)
    {
        UTCDateTime myDateTime,gmtDateTime;
        str         strDate;   
        //The sequence 123 describes the position of day (1), month (2), year (3).
        int         intSeq;
       
        Timezone    myTimeZone  = Timezone::GMTPLUS0800BEIJING_CHONGQING_HONGKONG;
        ;
        // Sunday, 21 Feb 2010 19:05:15 GMT
        strDate     =   "21 Feb 2010 19:05:15";
        intSeq      =   123;
        myDateTime  =   str2datetime(strDate,intSeq);
        info(strFmt("datetime in GMT:       %1",datetime2str(myDateTime)));
       
        myDateTime  =   DateTimeUtil::applyTimeZoneOffset(myDateTime,myTimeZone);
        info(strFmt("datetime in GMT+8:     %1",datetime2str(myDateTime)));
       
        //myDateTime  =   str2datetime(strDate,intSeq);
        gmtDateTime =   DateTimeUtil::removeTimeZoneOffset(myDateTime,myTimeZone);   
        info(strFmt("datetime in GMT:       %1",datetime2str(gmtDateTime)));
    }

  • Blue Wang Profile Picture
    on at
    RE: How to convert string to UTCDateTime?

    HI Junior,

    You can  convert RFC1123 string  time format to DateTime,and then convert it to UTCDateTime.

    DateTime zdt = DateTime::Parse("Thu, 25 Aug 2016 08:59:00 GMT" );
    
    udateTime = Global::CLRSystemDateTime2UtcDateTime(zdt);

    8244.PNG

  • zhifeng Profile Picture
    on at
    RE: How to convert string to UTCDateTime?

    Please refer this thread: https://community.dynamics.com/ax/f/microsoft-dynamics-ax-forum/125802/converting-string-into-datetime

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

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

#1
Sohaib Cheema Profile Picture

Sohaib Cheema 775 User Group Leader

#2
Martin Dráb Profile Picture

Martin Dráb 634 Most Valuable Professional

#3
André Arnaud de Calavon Profile Picture

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

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans