diff --git a/App/Controllers/AdminController.php b/App/Controllers/AdminController.php index 594af83..7228e9a 100644 --- a/App/Controllers/AdminController.php +++ b/App/Controllers/AdminController.php @@ -84,10 +84,7 @@ public function create() $post->setAutor($this->app->getAuth()->getLoggedUserName()); $post->setNazov($this->request()->getValue('nazov')); $post->setPopis($this->request()->getValue('popis')); - $inputString = $this->request()->getValue('datumPublikovania'); - $dateTime = new DateTime($inputString); - $outputString = $dateTime->format('d.m.Y'); - $post->setDatumPublikovania($outputString); + $post->setDatumPublikovania($this->request()->getValue('datumPublikovania')); $urlInput = (string)($this->request()->getValue('url')); $post->setZdroj($urlInput); diff --git a/App/Controllers/AuthController.php b/App/Controllers/AuthController.php index 5373fa1..d69534c 100644 --- a/App/Controllers/AuthController.php +++ b/App/Controllers/AuthController.php @@ -51,4 +51,4 @@ public function logout(): Response $this->app->getAuth()->logout(); return $this->html(); } -} +} \ No newline at end of file diff --git a/App/Models/Post.php b/App/Models/Post.php index ea94c12..dcfbf36 100644 --- a/App/Models/Post.php +++ b/App/Models/Post.php @@ -62,10 +62,11 @@ public function getDatumPublikovania(): string return $outputString; } - public function setDatumPublikovania(string $datumPublikovania): void + public function setDatumPublikovania(string $datumPublikovaniaa): void { - $formattedDate = date('Y-m-d', strtotime($datumPublikovania)); - $this->datumPublikovania = $formattedDate; + $dateTime = new DateTime($datumPublikovaniaa); + $outputString = $dateTime->format('Y-m-d'); + $this->datumPublikovania = $outputString; } public function getZdroj(): string