Exporting Date-Times in Iso Format
See original GitHub issueI want to export date/time values to JSON formatted as ISO 8601 values
My current script:
const XLSX = require('xlsx');
...
const file = XLSX.readFile(path,{cellDates:true, cellNF:false});
for (sheet in file.Sheets){
//remove prerendered values, otherwise dateNF is ignored
for (cellref in sheet){
const c = sheet[cellref];
if(c.t==="d"){
delete c.w;
delete c.z;
}
}
const format = "YYYY-MM-DD hh:mm:ss";
//const format = "YYYY-MM-DDThh:mm:ss"; throws exception as it doesn't recognize T
const data = XLSX.utils.sheet_to_json(sheet, {header: 1, dateNF:format});
.....
}
The cells itself already contain the correct datetime inside the v(alue) attribute.
I suggest an option like XLSX.utils.sheet_to_json(sheet, {header: 1, ExportDatesAsISO:true});
Test data: datum.xlsx
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:5 (2 by maintainers)
Top Results From Across the Web
c# - Given a DateTime object, how do I get an ISO 8601 date ...
FYI the formatexception's message is: "A UTC DateTime is being converted to text in a format that is only correct for local times....
Read more >Standardize on ISO8601 for date and time exports in Briefcase ...
I believe that Central exports SubmissionDate as ISO 8601, and for any date / time / dateTime field, passes through whatever value was...
Read more >How to Switch Microsoft Excel to ISO 8601 Standard Date ...
In today's video, I'm going to show you how to switch your Windows PC to the ISO 8601 standard date format. This will...
Read more >How do I enter dates in ISO 8601 date format (YYYY-MM-DD ...
I tried to enter this date in ISO 8601 format (YYYY-MM-DD) in Excel 2010: 2012-04-08 , but Excel automatically converts the date format...
Read more >The datetime string must match ISO 8601 format
Solved: I have a column with date and time in excel and there are empty values. I need to export the table into...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This script would work for me but feels just wrong:
Thank you, works perfect!