Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Unanswered

Add user's UTC timezone to jscript

(0) ShareShare
ReportReport
Posted on by 135

Hi All,


I use this script to populate a text field with the day, month and year.
For example 16-4-1985 returns 16 april 1985

New_datum is the date field and new_datumtekst is the tekst field

The problem:
Sometimes I get a wrong date in the text field.
For Example
1-4-1947 returns 31 maart 1947 instead of 1 april 1947

To fix this I probably need to add the user's UTC timezone. How can I do that?

function datumtekst(ExecutionContext){

if (ExecutionContext.getFormContext().getAttribute("new_datum").getValue() != null)
{
var Year = ExecutionContext.getFormContext().getAttribute("new_datum").getValue().getFullYear();
var Month = ExecutionContext.getFormContext().getAttribute("new_datum").getValue().getMonth();
var Day = ExecutionContext.getFormContext().getAttribute("new_datum").getValue().getDate();
var arr = new Array( "januari", "februari","maart","april","mei","juni","juli","augustus","september","oktober","november","december");
ExecutionContext.getFormContext().getAttribute("new_datumtekst").setValue(Day.toString()+" "+arr[Month] +" "+Year.toString());
ExecutionContext.getFormContext().getAttribute("new_datumtekst").setSubmitMode("always");
}
}

Thank you in advance.

Jan

  • SamiraM Profile Picture
    SamiraM 571 on at
    RE: Add user's UTC timezone to jscript

    Check the below post

    community.dynamics.com/.../782975

  • Jonathan Randall Profile Picture
    Jonathan Randall 50 on at
    RE: Add user's UTC timezone to jscript

    You might take a look at the getTimeZoneOffsetMinutes function.

    docs.microsoft.com/.../usersettings

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.

Helpful resources

Quick Links

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,403 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans