Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excel is not storing exact date. Preserving last day #2644

Open
uchakula13 opened this issue Apr 5, 2022 · 4 comments
Open

Excel is not storing exact date. Preserving last day #2644

uchakula13 opened this issue Apr 5, 2022 · 4 comments

Comments

@uchakula13
Copy link

Hi,
I am using SheetJs and trying to store date into excel sheet. I noticed the date records are storing incorrectly,
Ex - when i try to store 04-05-2022 , it is storing 04-04-2022. It is missing 1 day and storing previous date.
Am using latest version 0.18.5 . Please advise

@reviewher
Copy link
Contributor

Can you share an example file and your system timezone?

@chacabuk
Copy link

chacabuk commented Apr 8, 2022

This is an old issue...

Is not one day left, ist just a few seconds left
For example 20/12/2021 00:00:00 is export as 19/12/2021 23:59:12

My timezone is -3

a simple example to reproduce:

    const exportData = [
      { date: new Date('2021/12/20 00:00:00'), name: 'Peter' },
      { date: new Date('2021/12/30 18:30:00'), name: 'Jhon' },
    ]

    const wb: XLSX.WorkBook = XLSX.utils.book_new();
    const ws: XLSX.WorkSheet = XLSX.utils.json_to_sheet(exportData, { dateNF: 'dd/mm/yyyy HH:mm:ss' });

    ws['!cols'] = [{ wch: 30 }, { wch: 30 }];

    XLSX.utils.book_append_sheet(wb, ws, 'Data');
    XLSX.writeFile(wb, 'data.xlsx');
date name
19/12/2021 23:59:12 Peter
30/12/2021 18:29:12 Jhon

@SheetJSDev
Copy link
Contributor

Atlantic/Azores h/t @ruitalia . The timezone had fractional offset -1:42:40 in 1900

@mrichard95
Copy link

I'm also using version 0.18.5 and see the same issue in India Standard Time zone. It looks like 10 seconds is being subtracted off of the time.

Date in Excel File: 7/5/2023

Result after XLSX.read:
{
"t": "d",
"v": "2023-07-04T18:29:50.000Z",
"z": "m/d/yy"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants