You must be logged in to post your query.
Home › Forums › Chart Support › canvasJS.formatDate() and IE 11 specific error
Tagged: formatDate
Our date data comes to us as YYYY=MM-DD.
We discovered by accident that CanvasJS.formatDate('2017-08-30','MMM D, YYYY') will output Aug 29, 2017, not Aug 30…
CanvasJS.formatDate('2017-08-30','MMM D, YYYY')
However CanvasJS.formatDate('2017-08-30 00:00:01','MMM D, YYYY') will output Aug 30, 2017.
CanvasJS.formatDate('2017-08-30 00:00:01','MMM D, YYYY')
In setting our title we began using
axisXOption.title = CanvasJS.formatDate(json.dataset.start_date + ' 00:00:01','MMM D, YYYY') + ' to ' + CanvasJS.formatDate(json.dataset.end_date + ' 00:00:01','MMM D, YYYY');
Works in MS Edge, Chrome, FF etc. However we find that in IE 11 and previous we see
SCRIPT5022: Exception thrown and not caught canvasjs.min.js (67,13)
We will add some error handling on our end but can you advise as to how we get correct, formatted dates without this invalid date issue in IE 11?
http://jsfiddle.net/9vkjpegs/1/ will show xAxis title on Chrome/FF/MS Edge. On IE 11 (line 154 of fiddle)
http://jsfiddle.net/9vkjpegs/ will work in IE 11 due to commented out line 154
Kathy,
Thanks for reporting. We are looking into the issue. We will get back to you at the earliest.
____________ Indranil Deo, Team CanvasJS
We looked into your issue and observed that the ISO-format for date-time is (YYYY-MM-DDTHH:MM:SSZ), which is different from what you are using.
(YYYY-MM-DDTHH:MM:SSZ)
Please take a look at the following pages for more details on JavaScript Date Formats.
JavaScript Date Format W3Schools Date and Time Strings (JavaScript)
I have updated the fiddle please take a look.
___________ Indranil Deo, Team CanvasJS
Thank you very much. Is it expected behavior that CanvasJS.formatDate('2017-08-30','MMM D, YYYY') will output Aug 29, 2017, not Aug 30?
The formatDate() is working fine on our side. Please create a jsfiddle reproducing the issue so that we can look into it and help you better.
formatDate()
Thank you for the reply. This fiddle demonstrates the issue I see. http://jsfiddle.net/qzgtf8bt/
CanvasJS.formatDate(‘2017-08-30′,’MMM D, YYYY’) outputs Aug 29, 2017, not Aug 30.
We tried reproducing the issue with your jsfiddle, but it seems to be working fine. Here is the screenshot. Can you please provide complete browser and OS details, so that we can look into it and help you out.
—— Sanjoy Debnath Team CanvasJS
Thank you for the reply. OS is Windows 10 Home. This set of screenshots shows OS and 4 up-to-date browsers with same results: Chrome, IE 11, MS Edge, and FireFox. Version information for all is in screenshot.
https://imgur.com/3rq88jy
JavaScript Date constructor treats string as UTC format, not local. However, while displaying this date is converted into Local time zone, which makes the difference as observed in your jsFiddle.
You can take a look at this work-around to overcome this issue. You can also take a look at this page for further clarification.
—- Sanjoy Debnath, Team CanvasJS
You must be logged in to reply to this topic. Login/Register