Skip to content

Commit

Permalink
Merge pull request #2974 from bolt/bugfix/date-format-on-params
Browse files Browse the repository at this point in the history
Fix the date format expected for params like 'today'
  • Loading branch information
bobdenotter authored Nov 29, 2021
2 parents 9ca8374 + d0a43ea commit a87c872
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Storage/SelectQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Bolt\Entity\Field\CheckboxField;
use Bolt\Entity\Field\NumberField;
use Bolt\Entity\Field\SelectField;
use Carbon\Carbon;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Query\Expr\Andx;
use Doctrine\ORM\Query\Expr\Base;
Expand Down Expand Up @@ -329,7 +330,7 @@ public function build(): QueryBuilder
$fieldName = preg_replace('/(_[0-9]+)$/', '', $key);
// Use strtotime on 'date' fields to allow selections like "today", "in 3 weeks" or "this year"
if (in_array($fieldName, $dateFields, true) && (strtotime($param) !== false)) {
$param = date('c', strtotime($param));
$param = Carbon::parse((string) strtotime($param))->toIso8601ZuluString('milisecond');
}

if (in_array($fieldName, $this->regularFields, true) && ! in_array($fieldName, $numberFields, true)) {
Expand Down

0 comments on commit a87c872

Please sign in to comment.