Skip to content

Commit 0caf6bb

Browse files
committed
Merge pull request #73 from yaramayer/doc-timezone-date
[TASK] updated documentation for working with dates
2 parents 223652b + d36f6f3 commit 0caf6bb

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ TYPO3:
321321
type: date
322322
include_in_all: false
323323
format: 'date_time_no_millis'
324-
indexing: '${(node.hiddenBeforeDateTime ? Date.format(node.hiddenBeforeDateTime, "Y-m-d\TH:i:s") + "Z" : null)}'
324+
indexing: '${(node.hiddenBeforeDateTime ? Date.format(node.hiddenBeforeDateTime, "Y-m-d\TH:i:sP") : null)}'
325325
```
326326

327327
There are a few indexing helpers inside the `Indexing` namespace which are usable inside the
@@ -377,6 +377,29 @@ An example:
377377
**For a search user interface, checkout the Flowpack.SearchPlugin package**
378378

379379

380+
## Working with Dates
381+
382+
As a default, ElasticSearch indexes dates in the UTC Timezone. In order to have it index using the timezone
383+
currently configured in PHP, the configuration for any property in a node which represents a date should look like this:
384+
385+
```
386+
'My.Blog:Post':
387+
properties:
388+
date:
389+
search:
390+
elasticSearchMapping:
391+
type: 'date'
392+
format: 'date_time_no_millis'
393+
indexing: '${(value ? Date.format(value, "Y-m-d\TH:i:sP") : null)}'
394+
```
395+
396+
This is important so that Date- and Time-based searches work as expected, both when using formatted DateTime strings and
397+
when using relative DateTime calculations (eg.: `now`, `now+1d`).
398+
399+
For more information on ElasticSearch's Date Formats,
400+
[click here](http://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html).
401+
402+
380403
## Debugging
381404

382405
In order to understand what's going on, the following commands are helpful:

0 commit comments

Comments
 (0)