Giter Site home page Giter Site logo

Comments (6)

flaviendelangle avatar flaviendelangle commented on June 16, 2024 1

Thanks @michelengelen !

Just wanted to add that that if you have a string date stored in your database, then I would avoid converting it to a Date object then to a dayjs object, passing the string directly to dayjs is probably safer.

from mui-x.

LukasTy avatar LukasTy commented on June 16, 2024 1

@imparvez I think that @flaviendelangle suggested avoiding the extra headache of re-creating date objects of different types if there is no need for that.
Consider just passing a string of the date to the dayjs.utc function in turn avoiding the intermediate Date object usage.

- dayjs.utc(new Date(Date.UTC(2022,3,17)));
+ dayjs.utc('2022-04-17');

from mui-x.

michelengelen avatar michelengelen commented on June 16, 2024

The implementation is correct. I did adjust your example a bit by using the new Date(Date.UTC()) construct. Check it here.

I do know that there are some problems with using dayjs with timezones, especially when a timezone with a 00:00/00:00 offset is used.

Is there anythig else I can help you with?

from mui-x.

imparvez avatar imparvez commented on June 16, 2024

Thank you @michelengelen for your help. I think this helps me a lot. And also thank you for the heads-up about dayjs

from mui-x.

michelengelen avatar michelengelen commented on June 16, 2024

Great that I could help you. I'll close this issue now.
Feel free to reopen if you have questions regarding this. Thanks! 🙇🏼

from mui-x.

imparvez avatar imparvez commented on June 16, 2024

@flaviendelangle but I think when working with UTC time standard, v6 date picker doesn't behave what it should be and for that reason @michelengelen has suggested to use new Date(Date.UTC()). Correct me if I'm wrong? Thanks

from mui-x.

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.