Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
@AbdulSadikYalcin Can you provide context about where $this->currentUser is getting called from? Service, controller, form, etc? And does your editor hint what the type of $this->currentUser is? It is a little hard to guess here, but I suspect you have an Account and not a User. This is a really confusing part of core, where when you have an Account you need to load the full user for some scenarios.
In addition to the answers below, you should also consider that a Drupal 4.7 site that hasn't been touched is likely compromised, either the site itself from unapplied patches or issued addressed in later versions, or the server itself since the Apache 1.x / PHP 4.x.
I think you may be going down a rabbit hole with the modules at this point. Can you edit if your actual composer.json? If this is an older site, I suspect you have some root dependencies that are no longer needed (ie, your composer.json hasn't tracked with changes to the best practices).
@Kevin Unix timestamps by definition are the number of seconds (minus leap second) since 00:00:00 UTC on 1 January 1970. Internally, Drupal does everything in UTC ; time zones are an input/output thing.
Have you put xdebug on this or have you verified via Storm / IDE that all of the types are correct? What type is $this coming in as? I think you have one of two problem. (1) User vs Account object or (2) String vs DateTimeZone problem. I am on wrong computer, but I don't think you need the explicit timezone_open calls. I think proper DateTimeZone objects are always passed around in the API.
I am trying to find my writeup about this. I suspect it was an answer here, but I can't find it. I would add an answer here, but it has been a few years since I have done this. You are on the right path. I believe your next step would be to take your new composer.json, and then copy it into your site. Then rename directories to match the installer paths, and delete what would be the build artifacts managed by composer. Then composer install ; drush cr.