Coder Social home page Coder Social logo

Comments (4)

amandiobm avatar amandiobm commented on September 28, 2024 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.

maverick504 avatar maverick504 commented on September 28, 2024 2

@amandiobm Ohhh i see. Thank you!

from laravel-timezone.

jamesmills avatar jamesmills commented on September 28, 2024 2

This is certainly the best answer. Thank you @amandiobm

from laravel-timezone.

d4rkd0s avatar d4rkd0s commented on September 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.