Sir*_*rus 0 datetime x++ axapta date-formatting dynamics-ax-2012
我需要以这种格式获取日期/时间。2016/05/25 17:08:22
X++ 2012, . 我试图使用 DateTimeUtil::getSystemDateTime()) 但不确定参数是否正确
以下作业应该让您了解如何进行格式化。
static void FormatDateTimeJob(Args _args)
{
utcDateTime now = DateTimeUtil::utcNow();
str formattedOutput;
formattedOutput = DateTimeUtil::toFormattedStr(
now,
321,
DateDay::Digits2,
DateSeparator::Slash,
DateMonth::Digits2,
DateSeparator::Slash,
DateYear::Digits4,
TimeSeparator::Colon,
TimeSeparator::Colon);
info(formattedOutput);
}
Run Code Online (Sandbox Code Playgroud)
当然,您可能希望在像这样格式化值之前应用时区
now = DateTimeUtil::applyTimeZoneOffset(
now,
DateTimeUtil::getClientMachineTimeZone());
Run Code Online (Sandbox Code Playgroud)