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

Can't format datepicker result #71

Closed
mikeymileos opened this issue Jun 1, 2013 · 11 comments
Closed

Can't format datepicker result #71

mikeymileos opened this issue Jun 1, 2013 · 11 comments

Comments

@mikeymileos
Copy link

Hey, thanks for making this simple and light datepicker!

I'm trying to implement it in a form in Joomla 3, and have tried several different ways to format the date it gives, but no matter what I try, I end up with something like this: "Sat Jun 01 2013".

It looks nice, but it's not in the format required to pass to this external site's page which I can't change.

Any idea on why it won't format?

@elwayman02
Copy link
Contributor

@mikeymileos : are you using moment.js to format your dates? Pikaday is configured to play nice with Moment, which you can use to produce any kind of formatting you want.

@mikeymileos
Copy link
Author

I tried but it didn't work. Can you give me an example syntax on how to
format the date?
I used the moment.min.js. Was this sufficient?

On Tue, Jun 4, 2013 at 12:47 PM, elwayman02 notifications@github.comwrote:

@mikeymileos https://github.com/mikeymileos : are you using moment.js
to format your dates? Pikaday is configured to play nice with Moment, which
you can use to produce any kind of formatting you want.


Reply to this email directly or view it on GitHubhttps://github.com//issues/71#issuecomment-18934169
.

@elwayman02
Copy link
Contributor

Ok, let's say that I want my date formatted to be "2013-06-01" (same as your date above). Here's what I'd do:

var dateString = moment(pikaday.getDate()).format("YYYY-MM-DD");

dateString would be "2013-06-01", then.

@mikeymileos
Copy link
Author

Ahh ok, I will try that.

I had been trying things like picker.format("DD-MM-YYYY"); or picker.format
= "DD-MM-YYYY")
I tried to use the constructor option format: "DD-MM-YYYY" but to no avail.

I was kinda just stabbing in the dark with the first two, cause I don't
have an IDE and didn't look in the .js to see what classes and methods and
properties take what parameters and stuff.

On Tue, Jun 4, 2013 at 12:55 PM, elwayman02 notifications@github.comwrote:

Ok, let's say that I want my date formatted to be "2013-06-01" (same as
your date above). Here's what I'd do:

var dateString = moment(pikaday.getDate()).format("YYYY-MM-DD");

dateString would be "2013-06-01", then.


Reply to this email directly or view it on GitHubhttps://github.com//issues/71#issuecomment-18934664
.

@mikeymileos
Copy link
Author

By the way, I was wrong when I said that it wasn't passing the date
properly to the new page. That part is working, just the formatting was off.

On Tue, Jun 4, 2013 at 1:02 PM, Mikey Mileos michaelmileos@gmail.comwrote:

Ahh ok, I will try that.

I had been trying things like picker.format("DD-MM-YYYY"); or
picker.format = "DD-MM-YYYY")
I tried to use the constructor option format: "DD-MM-YYYY" but to no avail.

I was kinda just stabbing in the dark with the first two, cause I don't
have an IDE and didn't look in the .js to see what classes and methods and
properties take what parameters and stuff.

On Tue, Jun 4, 2013 at 12:55 PM, elwayman02 notifications@github.comwrote:

Ok, let's say that I want my date formatted to be "2013-06-01" (same as
your date above). Here's what I'd do:

var dateString = moment(pikaday.getDate()).format("YYYY-MM-DD");

dateString would be "2013-06-01", then.


Reply to this email directly or view it on GitHubhttps://github.com//issues/71#issuecomment-18934664
.

@elwayman02
Copy link
Contributor

passing format: "DD-MM-YYYY" is valid in the constructor for sure...but you have to make sure that you include moment before you include pikaday so that it can access the formatting functions itself.

@mikeymileos
Copy link
Author

Oh, I included moment after, but didn't call them til way after. It's in a
Joomla page, and I included them in the template's main page, and I call it
in a module which is loaded way later. Ok, I'll try switch the includes
around.

On Tue, Jun 4, 2013 at 1:05 PM, elwayman02 notifications@github.com wrote:

passing format: "DD-MM-YYYY" is valid in the constructor for sure...but
you have to make sure that you include moment before you include pikaday so
that it can access the formatting functions itself.


Reply to this email directly or view it on GitHubhttps://github.com//issues/71#issuecomment-18935316
.

@mikeymileos
Copy link
Author

Ok, as soon as I changed the include order it formatted the date (using the
constructor which I guess I had already set).

Thanks for your help!

On Tue, Jun 4, 2013 at 1:07 PM, Mikey Mileos michaelmileos@gmail.comwrote:

Oh, I included moment after, but didn't call them til way after. It's in a
Joomla page, and I included them in the template's main page, and I call it
in a module which is loaded way later. Ok, I'll try switch the includes
around.

On Tue, Jun 4, 2013 at 1:05 PM, elwayman02 notifications@github.comwrote:

passing format: "DD-MM-YYYY" is valid in the constructor for sure...but
you have to make sure that you include moment before you include pikaday so
that it can access the formatting functions itself.


Reply to this email directly or view it on GitHubhttps://github.com//issues/71#issuecomment-18935316
.

@elwayman02
Copy link
Contributor

No problem, I think there's a comment about it on the Pikaday documentation. Since Pikaday is both standalone and can use Moment, it has to know that Moment exists WHEN it's brought in as a dependency, or else it goes into standalone mode and doesn't try to use Moment.

@mikeymileos
Copy link
Author

Ahh, I missed that part. I only saw the part where it said without moment
it will use the default formatting and so I got moment.min.js and added it.
Ok, thanks again!

On Tue, Jun 4, 2013 at 1:11 PM, elwayman02 notifications@github.com wrote:

No problem, I think there's a comment about it on the Pikaday
documentation. Since Pikaday is both standalone and can use Moment, it has
to know that Moment exists WHEN it's brought in as a dependency, or else it
goes into standalone mode and doesn't try to use Moment.


Reply to this email directly or view it on GitHubhttps://github.com//issues/71#issuecomment-18935667
.

@rikkert
Copy link
Member

rikkert commented Jun 7, 2013

Als see documentation in the README file and the examples in the example dir.

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

No branches or pull requests

3 participants