0
Cake\ORM\Entity Object
(
    [id] => 1
    [lead_id] => 9
    [policy_start_date] => Cake\I18n\FrozenDate Object
        (
            [time] => 2011-07-01T00:00:00+00:00
            [timezone] => UTC
            [fixedNowTime] => 
        )
)

I am working in cakephp 3.x . This is my edit entity array. Here the date format as saved in database is showing 'Y-m-d'. Hence it is displaying date also in y-m-d in datepicker. But I am actually using datepicker format d-m-Y for eg. in this case such as 01/07/2011. I am storing in datebase as Y-m-d but i want to display in edit page as d-m-Y. How can I do it ?. Please help.

Bhinal Chauhan
  • 251
  • 3
  • 11
  • Possible duplicate of [cakephp 3.1 input field with european date format](https://stackoverflow.com/questions/34494962/cakephp-3-1-input-field-with-european-date-format) – Szymon Jul 20 '17 at 06:38

2 Answers2

0

You can do it using php.

$d = '2017-07-01';   //your date for formatting. such as policy_start_date
$date = date('d-m-Y',strtotime($d));
echo $date;
Nazmul Hasan
  • 1,937
  • 13
  • 21
0

Well I have found solution ,

 if (!empty($entity->policy_start_date)) {
            $entity['policy_start_date'] = $entity->policy_start_date->format('d/m/Y');
        }

this replaces the date format.

Bhinal Chauhan
  • 251
  • 3
  • 11