Looking for PowerObjects? Don’t worry, you’re in the right place! We’ve been part of HCL for several years, and we’ve now taken the final step in our acquisition journey: moving our website to the HCL domain. Nothing else is changing – we are still fanatically focused on Microsoft Business Applications!

PowerObjects Blog 

for Microsoft Business Applications


Good to Know JavaScript / CRM Date Time Difference

Post Author: Joe D365 |

Here at PowerObjects, we use JavaScript frequently. It's a powerful tool for Microsoft Dynamics CRM customizations. Now and then, we observe a funny quirk about how JavaScript and CRM work together. Take the JavaScript Date () function and how it relates to CRM date time, for instance.

JavaScript Date() function will take year, month, day, hours, minute and seconds as the parameters and convert it into Date object in dd/mm format for CRM. While in JavaScript Date(), the month starts in 0 for January. So, if we are feeding JavaScript Date() with 2012, 11, and 26 as the year, month and day parameters, it writes into CRM as 26 December 2012!

In the following screenshot, we can see our code and how the variable's month has the value 11. The new Date variable convertedDate via Date() has a result of 26 December 2012 instead of 26 November 2012.

fun with javascript and crm date time

Once we know that the month start value is different between JavaScript Date() and CRM, we can now convert Date correctly.

So repeat after me: JavaScript Date month start in 0 for January, CRM starts in 1 for January. The more you know!

If you found this post useful, here are some more posts about using JavaScript in CRM:

Happy CRM'ing!

Joe CRM
By Joe D365
Joe D365 is a Microsoft Dynamics 365 superhero who runs on pure Dynamics adrenaline. As the face of PowerObjects, Joe D365’s mission is to reveal innovative ways to use Dynamics 365 and bring the application to more businesses and organizations around the world.

PowerObjects Recommends