Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

defaultDate does not work with a date object #2391

Closed
Eonasdan opened this issue Sep 6, 2021 Discussed in #2389 · 5 comments
Closed

defaultDate does not work with a date object #2391

Eonasdan opened this issue Sep 6, 2021 Discussed in #2389 · 5 comments

Comments

@Eonasdan
Copy link
Owner

Eonasdan commented Sep 6, 2021

Discussed in #2389

Originally posted by deanstreetlab September 3, 2021
According to the docs, there is this defaultDate option which takes a JS Date arg. I tried setting it as below but the datepicker stops working. What's wrong in my setting?

new tempusDominus.TempusDominus(document.querySelector('#datepicker'), {
    display: {
        viewMode: 'years',
        components: {
            decades: false,
            year: true,
            month: true,
            date: true,
            hours: false,
            minutes: false,
            seconds: false,
         }
   }, //end display options
  restrictions: {
      minDate: new Date(1960, 0, 1),
      maxDate: new Date(2020, 11, 31), 
   }, //end restrictions options
  useCurrent: false,  
  defaultDate: new Date("2019-12-31") //NOT WORKING
 });
```</div>
@Eonasdan Eonasdan changed the title How to set defaultDate ? defaultDate does not work with a date object Sep 6, 2021
Eonasdan added a commit that referenced this issue Sep 6, 2021
@Eonasdan
Copy link
Owner Author

Closing.

@rczwojdrak
Copy link

rczwojdrak commented Aug 31, 2022

Still isn't working

Just check this with Simple Example from examples page:
new TempusDominus(document.getElementById('datetimepicker1'), { defaultDate: new Date("2019-12-31") });

I'm mean that if we set this date it does not show as picked in inputbox. Input box stays empty.

@Eonasdan Eonasdan reopened this Oct 24, 2022
@Eonasdan Eonasdan moved this to 🆕 New in Tempus Dominus Oct 24, 2022
@Eonasdan Eonasdan moved this from 🆕 New to 📋 Backlog in Tempus Dominus Oct 24, 2022
@Eonasdan Eonasdan moved this from 📋 Backlog to 🏗 In progress in Tempus Dominus Nov 3, 2022
@Eonasdan
Copy link
Owner Author

Eonasdan commented Nov 3, 2022

Hi please check this stackblitz. If the input is empty and the default date is provided, then the input will be set to the default date.

@Eonasdan Eonasdan moved this from 🏗 In progress to 👀 In review in Tempus Dominus Nov 4, 2022
Eonasdan added a commit that referenced this issue Nov 5, 2022
@Eonasdan Eonasdan moved this from 👀 In review to 🚀 Released in Tempus Dominus Nov 5, 2022
@Eonasdan
Copy link
Owner Author

Eonasdan commented Nov 5, 2022

Hello. This should be fixed in 6.2.7

@Eonasdan Eonasdan closed this as completed Nov 5, 2022
Repository owner moved this from 🚀 Released to ✅ Done in Tempus Dominus Nov 5, 2022
@khuongletikijob
Copy link

khuongletikijob commented Oct 29, 2024

Thanks, I have solved my problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

When branches are created from issues, their pull requests are automatically linked.

3 participants