How to change date format displayed

Hi guys,
As far as im concerned, the date format from phpmyadmin is yyyymmdd and one of the script has edit function but somehow the display seems wrong. For example when the db date = 2014-11-28
the shown date from the edit function will be listed in such way :


From the code i can see :

<?php echo $this->Form->input('enroll_date', array('class' => "form-control", 'type' => 'text',)); ?>

How do i set so that it will display correctly on the date format ?

Is this CakePHP? Can you try:

echo $this->Form->input('enroll_date', array('type' => 'date'));

Hi labofoz, thanks for the advise but if i do this, it will be placed as a drop down menu for all 3 (day, month and year) respectively.
I would prefer as for admin to manually key in the numeric in such format “__ / __ / ____” instead :smile:thanks

Is the date being stored as a timestamp or date field?

In either case, in mysql there’s the date_format function at query time. If the date is retrieved as a timestamp there’s php’s date function.

it is under “date”

Then if you have control of the query you can alter the format to pretty much whatever. If you’re using an ORM well, the loss of such flexibility is part of the price of ORM’s, so you’ll have to do it PHP side, changing the format from whatever the ORM is providing to the one you want.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.