What the best line of code for getting the current date time for user preferred time zone?
I guess both will return same output.
Have you check that?
Thanks
Girish S.
is that different from this..
DateTimeUtil::newDateTime(DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone()),
DateTimeUtil::getTimeNow(DateTimeUtil::getUserPreferredTimeZone()));
DateTimeUtil::applyTimeZoneOffset(DateTimeUtil::getSystemDateTime(), DateTimeUtil::getUserPreferredTimeZone()))
You can apply any time zone using applyTimeZoneOffset method
nice, but need the time zone applied
Hi brianmaric,
In addition to the Nuno Maia, You can also make use of "utcNow"method in "DateTimeUtil" class.
Thanks,
That's date not datetime
Try this
DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone()))
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Mansi Soni as our August 2025 Community…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Sohaib Cheema 665 User Group Leader
Martin Dráb 595 Most Valuable Professional
Yng Lih 558