Announcements
No record found.
What the best line of code for getting the current date time for user preferred time zone?
Try this
DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone()))
That's date not datetime
DateTimeUtil::applyTimeZoneOffset(DateTimeUtil::getSystemDateTime(), DateTimeUtil::getUserPreferredTimeZone()))
Hi brianmaric,
In addition to the Nuno Maia, You can also make use of "utcNow"method in "DateTimeUtil" class.
Thanks,
Girish S.
nice, but need the time zone applied
You can apply any time zone using applyTimeZoneOffset method
is that different from this..
DateTimeUtil::newDateTime(DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone()),
DateTimeUtil::getTimeNow(DateTimeUtil::getUserPreferredTimeZone()));
I guess both will return same output.
Have you check that?
Thanks
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.
Congratulations to our 2026 Super Stars!
Thanks to all of our 2025 Community Spotlight stars!
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Giorgio Bonacorsi 617
André Arnaud de Cal... 461 Super User 2026 Season 1
Syed Haris Shah 298 Super User 2026 Season 1