# |
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 |
# |
May 31st 2016, 09:07 |
birdy247 |
so its a series of dropdowns? |
# |
May 31st 2016, 09:07 |
Neon1024 |
Form->input(â??fooâ??, [â??typeâ?? => â??datetimeâ??]) |
# |
May 31st 2016, 09:07 |
birdy247 |
picker* |
# |
May 31st 2016, 09:07 |
birdy247 |
my use case is a datetime picket |
# |
May 31st 2016, 09:07 |
birdy247 |
but on the front end |
# |
May 31st 2016, 09:06 |
Neon1024 |
Standard MySQL datetime |
# |
May 31st 2016, 09:06 |
Neon1024 |
My datetimes are Y-m-d H:i:s in my database |
# |
May 31st 2016, 09:06 |
birdy247 |
what is the format of the string you are converting? |