Code Monkey home page Code Monkey logo

Comments (5)

lewismc avatar lewismc commented on August 24, 2024

@eniad do you have any idea how to fix this issue? I had a crack at it but I am not able to select the local timezone based upon the machine timezone settings.

from sitepod.

sigee avatar sigee commented on August 24, 2024

Hi @lewismc,
Sorry for the say in, but I would mention that, there are two solution to avoid this warning.

  1. In the php.ini you can set the default timezone. link
  2. In the php code you can set the actual timezone. link

I think you can set both of them if it is needed. The ini means the default fallback, but it is good when you can see the actual value in the code.

from sitepod.

lewismc avatar lewismc commented on August 24, 2024

Hi @sigee I appreciate you chiming in. Did you see the pull request I submitted? If you could scope it out and provide input it would be appreciated. Thank you

from sitepod.

lewismc avatar lewismc commented on August 24, 2024

Here is the PR https://github.com/nasa/sitepod/pull/10/files, I think it needs to be changed to be adaptive rather than restricted to UTC.

from sitepod.

sigee avatar sigee commented on August 24, 2024

@lewismc,
Unfortunatelly there is no way in standard php to get the user's timezone.
You can get the user's IP address and use a geoip api to get the location and timezone data.
Eg.: http://smart-ip.net/geoip-api

$ip     = $_SERVER['REMOTE_ADDR']; // means we got user's IP address 
$json   = file_get_contents( 'http://smart-ip.net/geoip-json/' . $ip);
// maybe it's good to add some checks (if/else you've got an answer and if json could be decoded, etc.)
$ipData = json_decode( $json, true);

if ($ipData['timezone']) {
    $timeZone = new DateTimeZone( $ipData['timezone']);
    date_default_timezone_set($timeZone->getName())
}
else {
    //not needed when php.ini is set.
    date_default_timezone_set('UTC');
}

The UTC should be set in the php.ini as I mentioned before.

from sitepod.

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.