Forum
Runway - Importing dates
I have been happily creating items in a collection (through the admin pages) that have a date field - quite a basic field:
<perch:content id="gamedate" label="Game Date" type="date" title="true" />
The date is saved in the database as 2017-03-24
for example.
I've been creating an import script to get a whole load of entries into the same collection - the dates are being imported from a CSV in the same format - 2010-09-04
. This date is saved in the database as 2010-09-04 00:00:00
(Using the same template above as the basis for the import).
One of my pages is filtering the items by the date, but as they can end up being stored in two different formats, the query doesn't always return the correct result. The date to filter by is being passed in the url in the format 2010-09-04
I can get round this by adjusting my filter to look for both formats:
'filter' => 'gamedate',
'match' => 'in',
'value' => perch_get('gamedate').','.perch_get('gamedate').' 00:00:00'
but this doesn't "feel right" having the date being stored in two formats for similar items.
EDIT:
Runway 3.0.14
PHP 7.1
MariaDB 10.2
How are you specifying the date when you import?
Importing from a CSV file, so the date is a string (
2010-09-04
). Usingfgetcsv
to grab each line, then passing the array value to the importer:Hmm, ok, I'll run some tests. I don't think we should be appending a time if
time="true"
isn't set on the template tag.