Search code examples
datetimetimezoneaxaptax++dynamics-ax-2012

Why the Info change the createdDateTime Table's field?


I have to stamp with info a createdDateTime field's Table,

I used this simple code:

info( strfmt("Date-Time: %1" , myTableDate.createdDateTime)  );

On myTableDate I have this value: 05/08/2015 12:48:57

On video in info I see this message:

Date-time: 05/08/2015 10:48:57

I see two hours less than the value stored in table. The field createdDateTime is the standard table's field .

Thanks all,

enjoy!


Solution

  • You will have to correct for timezone, as strFmt will not do it for you:

    info( strfmt("Date-Time: %1", DateTimeUtil::applyTimeZoneOffset(myTableDate.createdDateTime, DateTimeUtil::getUserPreferredTimeZone()));