Quantcast
Channel: Microsoft Dynamics CRM
Viewing all articles
Browse latest Browse all 123975

Blog Post: Good to Know JavaScript / CRM Date Time Difference

$
0
0

For the latest updates to this post please visit the original posting here: Good to Know JavaScript / CRM Date Time Difference

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!

The post Good to Know JavaScript / CRM Date Time Difference appeared first on PowerObjects.


Viewing all articles
Browse latest Browse all 123975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>