This job will explain the simple usage of DateTimeUtill class in AX.
static void UtcDateTimeClass(Args _args)
{
Date todaysDate;
;
//UTC Date Time
info("UTC Dates:");
//Get's today's utc date time.
info(strfmt('%1', DateTimeUtil::utcNow()));
//Get's minimum utc date time (i.e. 1/1/1900).
//Tough for this one you are not able to see the output as 1/1/1900, but when you set this to
//database field you will see 1/1/1900 set in the date control.
info(strfmt('%1', DateTimeUtil::minValue()));
//Get's minimum utc date time (i.e. 1/1/1900).
info(strfmt('%1', utcDateTimeNull()));
//Get's maximum utc date time (i.e. 12/31/2154).
info(strfmt('%1', DateTimeUtil::maxValue()));
//Convert UtcDateTime to normal date
todaysDate = DateTimeUtil::date(DateTimeUtil::utcNow());
info(strfmt('%1',todaysDate));
//How to get the time in user time zone
info(strfmt('%1', DateTimeUtil::applyTimeZoneOffset(DateTimeUtil::utcNow(),
DateTimeUtil::getUserPreferredTimeZone())));
}
Output:
No comments:
Post a Comment