I've set up a form where a user can input a date + time + timezone.
-- After submitting the form, in my controller, $this->request->data contains this:
[
'date' => [
'year' => '2015',
'month' => '02',
'day' => '12',
'hour' => '22',
'minute' => '54',
'timezone' => 'Europe/Paris'
]
]
After creating an entity using $table->newEntity($this->request->data), $entity->date contains:
object(Cake\I18n\Time) {
'time' => '2015-02-12T22:54:00+0000',
'timezone' => 'UTC',
'fixedNowTime' => false
}Although I was expecting it to contain:
object(Cake\I18n\Time) {
'time' => '2015-02-12T22:54:00+0000',
'timezone' => 'Europe/Paris',
'fixedNowTime' => false
}
OR
object(Cake\I18n\Time) {
'time' => '2015-02-12T21:54:00+0000',
'timezone' => 'UTC',
'fixedNowTime' => false
}Is this the expected behavior? If yes how can I (easily) correctly instantiate the date in my entity by taking into account the timezone submitted by the user?
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.
1 comment:
I was also going through same issue you have raised here, please find here my solution. I thought this would be helpful for anyone who is / will face the same issue.
You can change the time according to time zone in entity.
i.e $entity->start_time = $entity->start_time->i18nFormat('HH:mm:ss', 'Asia/Kolkata');
Post a Comment