Setting propel by default to getDate ("Ymd") date format to work better with zend toArray ()

My query returns an object with a date field

$obj = ObjectQuery::create()->findPK(11); 
  • var_dump($obj) shows me the date field as yyyy-mm-dd , as in the database
  • $obj->getThedate(); changes the format to mm/dd/yy , which I do not want to do
  • $obj->getThedate("Ymd"); gives me the same format in yyyy-mm-dd database

So, in order to get the data in the same format that they store in the database, I need to set the format when I get this specific date field, for example, the third row.

The problem is that I do not read the date field separately. I take the full $ obj as a whole and turn it into an array using Zend toArray() , so I can not control how toArray() reads the date field. Is there a way to set Propel to delivery in ("Ymd") format by default? Is there something in the prople configuration settings?

+4
source share
1 answer

The default format used by Propel for temporary columns can be configured using three build configuration parameters :

 propel.defaultTimeStampFormat = {Ymd H:i:s}|string propel.defaultTimeFormat = {%X}|string propel.defaultDateFormat = {%x}|string 

As you can see, the default date format is %x , which is the preferred date representation based on your locale . You must change it to %Y-%m-%d or shorthand %F

+9
source

Source: https://habr.com/ru/post/1340898/


All Articles