Not sure it works that way. Based on my reading of the docs and a lot of debug() statements, the controller is called twice. It is called to setup the view, the view is called, and then the controller is called again. Based on my testing, here is the series of events that take place:
- Controller edit() function called from a link
- The record ID and a usergroup is identified
- It is not a patch, post, or put so the save() if logic is ignored
- The associated data is identified
- The debug() is called and shows the correct time
- The timezone is changed which properly adjusts the date/time
- The debug() is called and shows the correct date/time in a different timezone
- The set()s are called
- The View is rendered
- The form end() is reached in the view once the Submit is clicked
- Control is sent back to the controller edit() function
- The record ID and a usergroup is identified again which seems like a total waste of time but that’s how it was Baked
- This time through, the request type is a post so it triggers the if statement
- The data is retrieved from the view form
- The debug is called and shows the incorrect date/time
- The save() is called
- The user is returned to the index() screen
Based on how it actually works, I’m not sure I understand your comment. When it comes back from the view, it never executes that code at the bottom of the edit() function.