Home forums Using CanvasJS canvasJS.formatDate() and IE 11 specific error

Tagged: 

This topic contains 8 replies, has 3 voices, and was last updated by  Sanjoy 1 week, 6 days ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #15958

    Kathy
    Member

    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…

    However CanvasJS.formatDate('2017-08-30 00:00:01','MMM D, YYYY') will output Aug 30, 2017.

    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

    #15972

    Indranil Deo
    Member

    Kathy,

    Thanks for reporting. We are looking into the issue. We will get back to you at the earliest.

    ____________
    Indranil Deo,
    Team CanvasJS

    #15974

    Indranil Deo
    Member

    Kathy,

    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.

    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

    #15977

    Kathy
    Member

    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?

    #15979

    Indranil Deo
    Member

    Kathy,

    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.

    ____________
    Indranil Deo,
    Team CanvasJS

    #15985

    Kathy
    Member

    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.

    #15987

    Sanjoy
    Moderator

    Kathy,

    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

    • This reply was modified 2 weeks, 1 day ago by  Sanjoy.
    #15992

    Kathy
    Member

    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.

    View post on imgur.com

    #16002

    Sanjoy
    Moderator

    Kathy,

    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

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.