DateTimeUtil class usage and User Preferred time zones in AX:

Hi,
Fetch the currentsystemdate:

systemdateget();

Fetch the currentsystemtime:

time2str(timenow(), timeseparator::colon, timeseparator::colon);

Fetch the Utcdatetime(without User preferred time zone):

datetimeutil::utcnow();

Fetch only date from utcdatetime:

datetimeutil::date(datetimeutil::utcNow());

Fetch only time from utcdatetime:

datetimeutil::time(datetimeutil::utcNow()); // This provides the time in integer format.
To convert time to str format ..

use.-> time2str(time(int), timeseparator::colon, timeseparator::colon);

User preferred time zones: // To fetch the date and time based on user preferred time zone.

Fetch the Utcdatetime(with User preferred time zone):

DateTimeUtil::newDateTime(systemDateGet(), timeNow());

Fetch only date from utcdatetime(with User preferred time zone):

DateTimeUtil::date(DateTimeUtil::applyTimeZoneOffset(DateTimeUtil::utcnow(), DateTimeUtil::getUserPreferredTimeZone()));

Fetch only time from utcdatetime(with User preferred time zone):

time2str(DateTimeUtil::time(DateTimeUtil::applyTimeZoneOffset(datetimeutil::utcNow(), DateTimeUtil::getUserPreferredTimeZone())), timeseparator::Colon, timeseparator::Colon);

Advertisements

One thought on “DateTimeUtil class usage and User Preferred time zones in AX:

  1. Hello there, I found your web site by the use of Google while
    searching for a related topic, your site came up, it seems to
    be great. I’ve bookmarked it in my google bookmarks.
    Hi there, just become aware of your blog via Google, and found that it’s
    really informative. I’m going to watch out for brussels. I’ll appreciate if you
    happen to continue this in future. Lots of folks will likely be benefited out of your writing.

    Cheers!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s