Comments (4)
@maverick504 Yep. Since a localhost IP address is 127.0.0.1
, GeoIP can not find a valid match so for that it will be using the default one. If the majority of your user is not in the default timezone, I would suggest exporting the GeoIP config file and change the default timezone. I did that in my case.
from laravel-timezone.
@amandiobm Ohhh i see. Thank you!
from laravel-timezone.
This is certainly the best answer. Thank you @amandiobm
from laravel-timezone.
Just noting here, so maybe it helps other folks...
I also experienced this with Laravel Vapor
But as a workaround this works on 95% of browsers...
<input id="tz" name="tz" type="hidden">
<script>
window.onload = function(){
document.getElementById("tz").value = Intl.DateTimeFormat().resolvedOptions().timeZone;
}
</script>
Then change your AuthenticatedSessionController.php
store()
method, to now include, Auth::user()->timezone = $request->tz;
public function store(LoginRequest $request)
{
$request->authenticate();
$request->session()->regenerate();
$user = Auth::user();
$user->timezone = $request->tz;
$user->save();
return redirect()->intended(RouteServiceProvider::HOME);
}
If you need the timezone
column, the migration is as follows, (credit this repo)
if (!Schema::hasColumn('users', 'timezone')) {
Schema::table('users', function (Blueprint $table) {
$table->string('timezone')->after('remember_token')->nullable();
});
}
from laravel-timezone.
Related Issues (20)
- Carbon diffForHumans
- PHP 8 Support? HOT 1
- Usage of protected instead of private function HOT 2
- Crashing Passport HOT 2
- Daylight savings (CET vs CEST?) HOT 3
- 'time_zone' instead of 'timezone' HOT 2
- Server 500 error when used with laravel octane / swoole
- Add timezone select to Jetstream profile page? HOT 1
- Updating wrong timezone automatically add manual feature HOT 4
- The library does not take the first found IP from 'lookup' config key HOT 1
- Formatting dates HOT 7
- Use language files HOT 1
- Stateless support - Illuminate\\Auth\\RequestGuard::loginUsingId does not exist HOT 3
- Inertia support HOT 1
- Laravel 10 support update please. HOT 3
- Laravel 10 future support. HOT 9
- Laravel 10 issue... HOT 8
- Replace the geoip with a better-maintained package HOT 13
- Issue with require HOT 4
- Laravel 11 Support HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-timezone.