# |
May 31st 2016, 09:18 |
Neon1024 |
Yes, so I can have in my CMS set a datetime in BST and itâ??ll save in UTC, and I can load a UTC from the db and marshall to local timezone |
# |
May 31st 2016, 09:18 |
birdy247 |
so with your script Neon1024, should it basiclaly override the cake stuff, and instead create with the local timezone and then convert to UTC |
# |
May 31st 2016, 09:18 |
storkovo |
birdy247: that snippet didnâ??t make it to the irc channel |
# |
May 31st 2016, 09:17 |
birdy247 |
cake has already converted my string into a datetime object |
# |
May 31st 2016, 09:17 |
birdy247 |
the easiest way I can see |
# |
May 31st 2016, 09:16 |
unorthodox |
How i can retrieve entity's id on beforeMarshal? |
# |
May 31st 2016, 09:15 |
birdy247 |
can you see that on IRC? |
# |
May 31st 2016, 09:14 |
Neon1024 |
I just have the 1 project where I need to do it really |
# |
May 31st 2016, 09:13 |
Neon1024 |
Hopefully something can be implemented in Chronos or CakePHP to deal with it in a concise and elegant way |
# |
May 31st 2016, 09:13 |
Neon1024 |
Perhaps have a look for an issue in Github, as youâ??re not alone trying to solve this problem |
# |
May 31st 2016, 09:13 |
Neon1024 |
I like the data type class though as it feels a logical fit |
# |
May 31st 2016, 09:12 |
birdy247 |
and have done on every other project |
# |
May 31st 2016, 09:12 |
birdy247 |
this is what I want to do :slightly_smiling_face: |
# |
May 31st 2016, 09:12 |
Neon1024 |
The suggestion at Cakefest was to store in UTC and write your own helper for front-end |
# |
May 31st 2016, 09:12 |
birdy247 |
I am clearly doing something wrong |
# |
May 31st 2016, 09:12 |
birdy247 |
this is my 3rd cake project where I have had to handle it differently! |
# |
May 31st 2016, 09:12 |
Neon1024 |
If all else fails, which it shouldnâ??t really, you can use good old PHP DateTime to do the same thing |
# |
May 31st 2016, 09:11 |
Neon1024 |
Take a look in Chronos then, might just be a different method name |
# |
May 31st 2016, 09:11 |
birdy247 |
but since upgrading, to 3.2. it doesnt work anymore |
# |
May 31st 2016, 09:11 |
birdy247 |
handled DST |
# |
May 31st 2016, 09:11 |
birdy247 |
it worked fine |
# |
May 31st 2016, 09:11 |
Neon1024 |
It was raised at Cakefest |
# |
May 31st 2016, 09:11 |
birdy247 |
$timeObject = new Time; $time = $timeObject->createFromFormat('d-m-Y H:i', $date, 'Europe/London')->setTimezone('UTC'); return $time; |
# |
May 31st 2016, 09:11 |
birdy247 |
I used to do this is the entity |
# |
May 31st 2016, 09:10 |
Neon1024 |
So your app doesnâ??t break in Oct |
# |
May 31st 2016, 09:10 |
Neon1024 |
So now you need to think about daylight savings time too |
# |
May 31st 2016, 09:10 |
birdy247 |
this is all I am trying to do |
# |
May 31st 2016, 09:10 |
Neon1024 |
Yep |
# |
May 31st 2016, 09:10 |
birdy247 |
but its says 10am UTC |
# |
May 31st 2016, 09:10 |
birdy247 |
yea, but if a user selects 10am, thats 10am our time so 9am UTC |
# |
May 31st 2016, 09:09 |
Neon1024 |
As it should be, UTC |
# |
May 31st 2016, 09:09 |
birdy247 |
but its the wrong timezone |
# |
May 31st 2016, 09:09 |
birdy247 |
its fine |
# |
May 31st 2016, 09:09 |
birdy247 |
If I let cake do it |
# |
May 31st 2016, 09:09 |
Neon1024 |
Sounds like youâ??re not letting things work for you |
# |
May 31st 2016, 09:08 |
birdy247 |
I literally lose the will to live with datetimes :( |
# |
May 31st 2016, 09:08 |
Neon1024 |
So I just let CakePHP infer the type from the data |
# |
May 31st 2016, 09:08 |
Neon1024 |
echo $this->Form->input('closes'); |
# |
May 31st 2016, 09:08 |
Neon1024 |
echo $this->Form->input('opens'); |
# |
May 31st 2016, 09:08 |
Neon1024 |
date_default_timezone_set('Europe/London'); |
# |
May 31st 2016, 09:07 |
Neon1024 |
But let me double check in the repo |