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

Date Format Question #13

Open
oleteacher opened this issue Dec 26, 2018 · 4 comments
Open

Date Format Question #13

oleteacher opened this issue Dec 26, 2018 · 4 comments

Comments

@oleteacher
Copy link

Excellent work, thank you for sharing!

Is there any way to format the date within simplyCountdown so that standard date pickers can be used? Example: I have input form and users pick a date using https://cdnjs.com/libraries/bootstrap-datetimepicker

Since most date / time pickers can use formats like "2018-12-31 23:55:21", is there way to use this format with simplyCountdown?

Thanks!

@VincentLoy
Copy link
Owner

Hello @oleteacher !
Thanks a lot for your support !

Actually, there is no way to do that directly. You'll have to parse the date given by the Bootstrap Datetimepicker plugin. But it's quite simple, I suppose that the datetimepicker plugin will give you a date object, so you can then get the year, month, day, etc.

Otherwise, if you want to contribute, we can easly improve simplyCountdown plugin to allow users to pass datetime object directly in parameters. The only thing we have to watch out is a priority system like :

  • If date object is given, use it for targetTmpDate
  • else, use other params to build targetTmpDate

@oleteacher
Copy link
Author

oleteacher commented Jan 17, 2019

Greets!

I had tooled around with the plugin and found no simple way to use with standard date/time pickers. If the opportunity arises in the future, will revisit and try to convert in classroom project:)

Thanks!

@VincentLoy
Copy link
Owner

Sound great ! Very happy that the plugin can be used in a educational way ! 😄 🎉

@VincentLoy
Copy link
Owner

VincentLoy commented Jan 18, 2019

I just remember that in the demo, I'm using the plugin with Date objects...

var d = new Date();

simplyCountdown('.simply-countdown-one', {
    year: d.getFullYear(),
    month: d.getMonth() + 1, // Because January is 0 and December is 11
    day: d.getDate(),
    // etc ...
});

So you can get the date object from the plugin and use it like in the example.

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

No branches or pull requests

2 participants