jQuery UI Widgets Forums Getting Started exportdata Date probs

This topic contains 2 replies, has 2 voices, and was last updated by  gruppenhaus 12 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • exportdata Date probs #121136

    gruppenhaus
    Participant

    Hi there,

    exporting a table to csv gives me the correct date:

    “Status”,”Anreise”,”An-Zeit”,”Abreise”,”Ab-Zeit”,”Organisation”,”Ansprechpartner”,”Telefon”,”Gäste”
    “Anfrage”,”31.10.2021″,”16:00″,”04.11.2021″,”10:00″,”Grömitz”,”Frau X Y”,”+49″,”10.00″

    (the 31.10.2021)

    Using XLS:

    <Row>
    <Cell ss:StyleID=”xls-style-3″><Data ss:Type=”String”>Anfrage</Data></Cell>
    <Cell ss:StyleID=”xls-style-4″><Data ss:Type=”DateTime”>2021-10-30T22:00:00.000Z</Data></Cell>
    <Cell ss:StyleID=”xls-style-5″><Data ss:Type=”String”>16:00</Data></Cell>

    there is the “2021-10-30T22:00:00.000Z”. Its one day earlier.

    Any idea?

    Regards
    Chris

    exportdata Date probs #121137

    ivanpeevski
    Participant

    Hello Chris,

    The problem comes from the way the Date object works in JavaScript. What you see in the browser is the date according to your local timezone, the difference in the day comes from the Date object, which converts the date from your local timezone to the UCT Timezone and then transfers it to Excel.

    I suggest storing your dates in format, which clearly states the timezone offset.
    For example, the following date 2020-04-30T21:00:00.000Z will be displayed as 2020-04-30 23:00:00 in the browser if the difference between your timezone and UCT is 2 hours. When you export the table, you will export the original 2020-04-30 21:00:00
    If you want your browser to display the UCT Time without applying your local timezone, you can manipulate the date column with cellsRenderer:

    cellsRenderer: function (row, column, value, rowData) {
        let date = new Date(value);
        date.setMinutes(date.getMinutes()+date.getTimezoneOffset())
        return new Intl.DateTimeFormat('de', {timeStyle: "medium",dateStyle: "medium"}).format(date)
    }

    If you have any other questions, please do not hesitate to contact us again!
    Best regards,
    Ivan Peevski
    jQWidgets Team
    https://www.jqwidgets.com

    exportdata Date probs #121157

    gruppenhaus
    Participant

    Hi Ivan,

    thanks a lot. Works well!

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

You must be logged in to reply to this topic.