Did not yet work on it but a client asked to pick timezone before setting a day. The idea is that user picks his timezone and then when making an update, the date field is updated based on his timezone. Any ideas on how to approach this? Will give feedback if having progress.
Now that I re-read your answer, how can I sum the hours. I mean PHP timezones are in the format of text, where I could retrieve the difference in hours. Will it work If I retrieve from the database the timezone user has selected? (for example America/Adak)
Use UTC time and after add hours through the data formatter. Better of you get DB with all timezone with + and - with all zone. Same as you have a date and use add days function.
I would use date add because if your database stores -2 for Africa or +6 for Australia or whatever then you could have NOW date add hours and it should work very well because the parameter it takes is exactly -2 or +6 etc.
Well don’t know what happened. Right after I changed the value back to negative inside the database it worked! Thank you guys, I will try to create a small tutorial on this.
Glad it is working now, wonder why it did not work a little while back. Seems strange. I wonder what happens with date add if it is 01:00 and the date add is set to hours and you input -2 needing it to go back to 23:00 on the previous day? I’m sure it’s working but just wondering why -5 worked and -10 not
It was 5 and -10. While initially I was trying to make it work with -10, when changed to 5 it worked. Then re-entered -10 and it worked that too. Who knows maybe it was something else, because I was changing other things too, that made it work with negative values too. Again thank you vey much for your help.
I’m having a similar issue where the negative value break the addHours function. I’ve not been able to fix it, but what I can tell is that in my case it doesn’t matter if it goes onto the day before or not, it’s just the negative value itself. There also seems to be an issue where days are added on top of hours, unintendidly.