Sabin Neagu
Sabin Neagu

Reputation: 722

CakePHP's CakeTime format for minutes

I don't understand the result of CakeTime::format when using %i.

debug(CakeTime::format('2014-01-10 15:00:00', '%Y-%m-%d %H:%i')); outputs false

debug(CakeTime::format('2014-01-10 15:00:00', '%Y-%m-%d %H:xx')); outputs 2014-01-10 15:xx

What is the correct format for minutes?

Upvotes: 0

Views: 250

Answers (2)

user2711870
user2711870

Reputation: 1

Did you try using M uppercase

debug(CakeTime::format('2014-01-10 15:25:00', '%Y-%m-%d %H:%M'));

In this case appears correctly as you wish to appear.

Upvotes: 0

cornelb
cornelb

Reputation: 6066

From the documentation

The formatting uses the option from strftime. And "M" is the right parameter for minute, as @user2711870 said.

However, CakePHP documentation is wrong:

// called via TimeHelper
echo $this->Time->format('%F %jS, %Y %h:%i %A', '2011-08-22 11:53:00');
// August 22nd, 2011 11:53 AM

This should be

echo $this->Time->format('2011-08-22 11:53:00', '%F %jS, %Y %h:%M %A');

Upvotes: 2

Related Questions