We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How to express this function in Phalcon?

How to express this function using Phalcon?

$fecha_oracle='12/02/2016'
$fecha = DateTime::createFromFormat('j-M-y', $fecha_oracle);

echo $fecha->format('d/m/Y');
edited Aug '16

Not sure what you mean about "this function", but afaik phalcon doesn't have any datetime objects; it uses the php built-in

The translation interface is passing it down to the actual implementor too, so that's no-go



81.2k

DateTime::createFromFormat Is this not found as object?



77.7k
Accepted
answer

Still not sure about your problem...

If it is an exception about DateTime class not found, then it's a namespace problem: either import it with the use keyword, or reference it with a preceding backslash: \DateTime::createFromFormat

Otherwise, yes, $fecha will be a DateTime object which is provided by standard PHP. Phalcon itself does not have any wrapper for formatting dates, so any custom functonality will have to be implemented by yourself



81.2k

Thanks No problem. I wanted to be sure before implementation