This is a quick post about using jQuery UI and Moment.js to render calendar UI within, for this case, SharePoint.
When using the CSOM, SharePoint will return DateOnly fields where the date value will likely need to be parsed in some way before you render the value for users. For example, today, 7/22/2015, will be returned as Wed Jul 22 00:00:00 PDT 2015. At the very least, you’ll likely want to split and rejoin (substring, etc.) the date to exclude the “00:00:00” time stamp before rendering it in any way considered to be “friendly”.
Now, if you use a simple calendar control from jQuery UI, you’ll want to take the parsing a bit further, and you’ll also need to convert something like the stamp above to read “7/22/2015”. Otherwise, by default, the date won’t mean anything to the jQuery UI calendar if you’ve casted a control using the datepicker() method.
You can imagine the HTML/jQuery:
$('#new-task-startdate').datepicker(); ... ... <input type="text" id="new-task-startdate"/>
var startDate = moment(spStartDate).format("MM/DD/YYYY");
And, to the point above, if you expect to cast dates back and forth between UTC and the local zone, or you need to render the local time according to city and country names, you’d have that added support with just a few more lines of code.