Giter Club home page Giter Club logo

Comments (6)

IonBazan avatar IonBazan commented on June 17, 2024

It is not faker issue as the date exists in the time zone you are using to generate the date (UTC I suppose). You can pass an optional argument for faker provider to generate the DateTime object in specified time zone matching your database to make sure it will be persisted. You may also want to verify your MariaDB and PHP default time zone settings as it will affect the rest of your app.

from faker.

pimjansen avatar pimjansen commented on June 17, 2024

Agree that Faker should return a valid date though in this case. Marking this as a bug

from faker.

pimjansen avatar pimjansen commented on June 17, 2024

I was wrong as it is as @IonBazan suggested. The instance will create a date on utc time which does not have daylight saving. There is a param for setting the timezone

from faker.

iBotPeaches avatar iBotPeaches commented on June 17, 2024

What I'm lost on it is why the default doesn't appear to be working. Yes that timezone is invalid in my timezone (Eastern) and I can see that via

➜  foo git:(master) php -i | grep 'timezone'
Default timezone => America/New_York
date.timezone => no value => no value

Though the docs say:

Methods accepting a $timezone argument default to date_default_timezone_get(). You can pass a custom timezone string to each method, or define a custom timezone for all time methods at once using $faker::setDefaultTimezone($timezone).

So I don't use any parameters so it should default to date_default_timezone_get() no?

➜  foo git:(master) php artisan tinker
Psy Shell v0.10.4 (PHP 7.4.11 — cli) by Justin Hileman
>>> date_default_timezone_get()
=> "UTC"
>>> 

Even the Laravel config:

    /*
    |--------------------------------------------------------------------------
    | Application Timezone
    |--------------------------------------------------------------------------
    |
    | Here you may specify the default timezone for your application, which
    | will be used by the PHP date and date-time functions. We have gone
    | ahead and set this to a sensible default for you out of the box.
    |
    */

    'timezone' => 'UTC',

This is where I got confused and just made a ticket. I'm not sure where the fault is.

from faker.

pimjansen avatar pimjansen commented on June 17, 2024

No idea neither however Faker is returning a date as expected where your DB returns an error. The generated date is a valid utc date this year

from faker.

IonBazan avatar IonBazan commented on June 17, 2024

@iBotPeaches Since you stay in America/New_York time zone, most probably your database time zone is set to America/New_York while your app is working in UTC. You should change the database default time zone to UTC too to avoid converting the date each time you want to persist or retrieve it from DB.

from faker.

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.