From 946d00ff930640d90ca9f2babd91dcc4a1e94f78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danyi=20D=C3=A1vid?= Date: Sun, 3 Sep 2017 20:10:34 +0200 Subject: [PATCH] * normalized date from input so DateTime can parse it --- src/App/Service/SmsStoreService.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/App/Service/SmsStoreService.php b/src/App/Service/SmsStoreService.php index f0f5e24..b6703c8 100644 --- a/src/App/Service/SmsStoreService.php +++ b/src/App/Service/SmsStoreService.php @@ -22,12 +22,13 @@ class SmsStoreService public function storeSms(string $hashKey, int $direction, array $requestData): bool { + $normalizedDate = str_replace("at ", "", $requestData['when']); $user = $this->ensureUserExists($hashKey); $sms = new Sms(); $sms->setDirection($direction) ->setContactName($requestData['contactName']) ->setContactNumber($requestData['contactNumber']) - ->setOccuredAt(new \DateTime($requestData['when'])) + ->setOccuredAt(new \DateTime($normalizedDate)) ->setOwner($user) ->setText($requestData['text']); $this->em->persist($sms);