Notifications
Announcements
No record found.
I have to set a field of type Date and time with current date and time + 5 hours how can I do that with JavaScript? Please provide solution.
thanks in advance
*This post is locked for comments
var currentDateTime = new Date();
Xrm.Page.getAttribute("xyz").setValue(currentDateTime);
new Date(); is the Client date not server date
Hi Milan
I have to add 5 hours more to the CurrentDateTime how can i do that?
new Date().addHours(5)
with JavaScript you can get only the client datetime, not the server one.
the code to add 5 hours is
var currentDate = new Date(); currentDate.setHours(currentDate.getHours()+5); Xrm.Page.getAttribute("field").setValue(currentDate);
Hi, I have two date time fields.
In the first field, if the date is set, then in the second date time field, the date should be automatically populated
with this format.
Field 1: 09/30/2016
Result of Field 2: 09/29/2017.
I have set the year but unable to set the Date.
So please help me with your suggestions.
how to do this..many time i tried this using javascript but i will get error..
Hi Dinesh,
Try setting the field by using the following:
Xrm.Page.getAttribute('nameOfDateTimeField').setValue(new Date());
Hi,
please refere to the following code
function Notify() {var currentDate = new Date();
currentDate.setHours(currentDate.getHours() + 5);alert(currentDate );Xrm.Page.getAttribute("scheduledend").setValue(currentDate);
}
User can get User Time Zone using WebAPI call for UserSettings and then he can adjust his System timezone value accordingly .
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 Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
SA-08121319-0 4
Calum MacFarlane 4
Alex Fun Wei Jie 2