Issues importing dates via csv

By: Tom Boltwood | Asked: 10/12/2022
ForumsCategory: General questionsIssues importing dates via csv
Tom BoltwoodTom Boltwood asked 2 years ago
I'm trying to import a CSV to create a searchable database. I have for the most part succeeded. However, some dates are imported as 01/01/1970. I thought it might be dates that are older than 5 years as the first entry to have an issue with this date is 23/11/2017. However, there is a start date and an end date for each entry and in this case the end date is 22/05/2023 and has also been imported as 01/01/1970. I then thought it might be that those entries didn't have a value for the previous column, however, that doesn't seem to be the case either. I have checked that the global settings are set to d/m/Y and also checked that the entries are all in this format too. It seems that the earliest date that has imported correctly is 03/01/2018
Rob LeVineRob LeVine replied 2 years ago

Is any date with the first two numbers greater than 12 successfully imported?

Tom BoltwoodTom Boltwood replied 2 years ago

Good question, I've checked so many different things, I didn't think to check that…

Tom BoltwoodTom Boltwood replied 2 years ago

I thought it had been cracked! No, there are no days greater than 12 that have been imported. The calendar localisation was set to English, not English/UK. I changed that and re-uploaded and it's still doing it…

Rob LeVineRob LeVine replied 2 years ago

Can you upload both the import CSV and the form XML so I can try it myself?

Tom BoltwoodTom Boltwood replied 2 years ago

I've done it now, as shown below, just reformatted to YYYY-MM-DD and it's come in fine.

Rob LeVineRob LeVine replied 2 years ago

Gotcha. I got confused thinking your solution didn't work.

Tom BoltwoodTom Boltwood replied 2 years ago

Made an edit as I wrote m/d/Y instead of d/m/Y!

1 Answers
Tom BoltwoodTom Boltwood answered 2 years ago

Right, it seems as if importing with d/m/Y format doesn't work. I'm guessing it's something to do with strotime() used in the import code. Formatting as YYYY-MM-DD imports okay. Luckily I can change the format in the spreadsheet.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right