RE: Getting only Date from Date time field using javascript
Hello,
I need to read Date value of one DateTime field in my Dynamics CRM Form using JavaScript.
I am able to read the value but it is not exactly same what I can see in CRM.
In CRM Form, selected value is: 17th May 2018
JavaScript Code return value as: Wed May 16 2018 00:00:00 GMT+0530 (India Standard Time)
CRM logged in user time-zone: GMT +10:00 Sydney
My time-zone: +5:30 India
JavaScript Code I am using is:
var dateFieldValue= Xrm.Page.getAttribute('MyDateField').getValue();
var year = dateFieldValue.getFullYear();
var month = dateFieldValue.getMonth();
var day = dateFieldValue.getDate();
new Date(year,month,day);
May I know how can I get exact date using JavaScript which I am selecting in DateTime control?
Thanks,
Mohit