I have the following code:
$currentDate = Carbon::now()->setTimezone('Europe/Stockholm');
$offset = $currentDate->utcOffset() * 60;
$currentDate->modify("+" . $offset . " seconds");
That basically adds offset to a date based on the given timezone. Instead of having the timezone hardcoded I would like to get the users timezone and use it instead since I generate some dynamic content that's different based on which timezone it is. This code is in my controller. Is there any way to access users local timezone and use it witin my controller code? I did some searching but couldn't find anything useful besides using some kind of GEO API that returns timezone for the given IP, for example https://ipgeolocation.io
Is this the only way or are there better solutions?