This date format 2016-04-21 is stored in the database, but it's display like 21.04.2014. on my website. This is very frustrating. Solution echo $object->field->format('Y-m-d'); is not good for me. I would like to define settings that this is not happening anymore. Sorry for my english.
Asked
Active
Viewed 503 times
0
-
This is a version of CakePHP 3.1 – user3661042 Apr 21 '16 at 08:13
-
what date format do you want? – Jason Joslin Apr 21 '16 at 08:19
-
Possible duplicate of [Show dates in a custom format](http://stackoverflow.com/questions/31635700/show-dates-in-a-custom-format) – ndm Apr 21 '16 at 08:56
-
Also **http://stackoverflow.com/questions/35676227/cakephp-3-2-change-default-date-format** – ndm Apr 21 '16 at 08:57
-
I want 2016-04-21 date format like saved in datebase. – user3661042 Apr 21 '16 at 09:33
1 Answers
0
Use this
$date="2016-04-21";
$require_date_format = date('d.m.Y', strtotime($date));//will out put 21.04.2016

sradha
- 2,216
- 1
- 28
- 48
-
-1 The question is about CakePHP, its date/time objects, and a global, configurable solution. What you are showing here is the cumbersome variant of the `format()` call in the question. – ndm Apr 21 '16 at 08:51