web
You’re offline. This is a read only version of the page.
close
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

I have the same question (0)
  • Jonathan Randall Profile Picture
    50 on at

    You might take a look at the getTimeZoneOffsetMinutes function.

    docs.microsoft.com/.../usersettings

  • SamiraM Profile Picture
    587 on at

    Check the below post

    community.dynamics.com/.../782975

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 72 Super User 2025 Season 2

#2
Daniyal Khaleel Profile Picture

Daniyal Khaleel 32 Most Valuable Professional

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 29 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans