Propel2 icon indicating copy to clipboard operation
Propel2 copied to clipboard

Temporal column getter doesn't support strftime format anymore

Open msarris opened this issue 9 years ago • 3 comments

The generated doc comment of the get method of a temporal type column still says this about the $format parameter: "The date/time format string (either date()-style or strftime()-style).".

It seems however that only date()-style is supported, as the format is passed to the format method of the DateTime object. (This used to be different in Propel 1.)

Will support for strtime come back (which is my preferred way of formatting because of localization support)?

msarris avatar Apr 09 '15 08:04 msarris

Will support for strtime come back (which is my preferred way of formatting because of localization support)?

\DateTime is the way you should use propel temporal columns, so the answer is no :)

You should do something like $model->getDateTimeColumn()->setTimezone(...)->format(...); for localization.

mpscholten avatar Apr 15 '15 15:04 mpscholten

Maybe this could be a PR for docs?

dereuromark avatar Jul 01 '20 13:07 dereuromark

Turns out, you can pretty easily add strftime-based getters to all tables through behaviors.

See https://github.com/mringler/propel-generate-strftime-getters-behavior

mringler avatar Jan 10 '21 20:01 mringler