Saturday, January 24, 2015

Re: cakephp 3.0 time and date

Hi Mark,

Thanks for the help

I saw YYYY-MM-dd format at http://book.cakephp.org/3.0/en/core-libraries/time.html#setting-the-default-locale-and-format-string

For now just did this inside the user layout as this doesn't affect the formatting of other datetime fields in the views…
<?php $dateuser = $this->Time->format(date('Y-m-d'), 'YYYY-MM-dd', null, $authuser['time_zone']); ?>

Using as below was affecting how datetimes are formatted inside views

AppController.php
public function beforeFilter(Event $event) {
….
$dateuser = Time::now();
$dateuser->setToStringFormat('YYYY-MM-dd');
$dateuser->timezone = $this->Auth->user('time_zone');
echo $dateuser;
$this->set(compact('dateuser'));
….
}

just noticed on a page default time formatting:

Domain Time Zone Active Created Modified
domain1.com US/Pacific 1 1/15/15, 12:48 AM 1/15/15, 12:48 AM

becomes:

Domain Time Zone Active Created Modified
domain1.com US/Pacific 1 2015-01-15 2015-01-15



Thanks,

Andras


> On Jan 24, 2015, at 4:27 AM, mark_story <mark.story@gmail.com> wrote:
>
> Your format looks incorrect, as you're not using date() compatible format values.
>
> -mark
>
> --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to the Google Groups "CakePHP" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
> To post to this group, send email to cake-php@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php.
> For more options, visit https://groups.google.com/d/optout.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: