GithubHelp home page GithubHelp logo

Comments (18)

gregmatthewcrossley avatar gregmatthewcrossley commented on June 28, 2024 2

For anyone using Ruby/Rails, I found that adding .strftime("%a %b %d %Y") to a Date fixed the issue.

from pikaday.

memoht avatar memoht commented on June 28, 2024

Adding moment.js makes this problem disappear, but still would be curious as to what I may have done wrong or whether or not this is a bug.

from pikaday.

dbushell avatar dbushell commented on June 28, 2024

Difficult to say what's going on here, doesn't look like you're doing anything wrong. Can you upload an example?

from pikaday.

memoht avatar memoht commented on June 28, 2024

Hello again David.
I created a simple Rails app and pushed it up to Github. I don't know what you use locally, so if you need me to push this out to Heroku so you can hit it from the web I can do that. I made you a collaborator. This app seems to reproduce the problem I experienced.

from pikaday.

rikkert avatar rikkert commented on June 28, 2024

Could you indeed please host it, I would like to have a look myself.

from pikaday.

memoht avatar memoht commented on June 28, 2024

I updated the app and pushed it to Heroku. I loaded a single post. It is a simple app, but hope it is useful for you. I'll keep it up for a week so you have enough time to check it out. The app is at http://backaday.herokuapp.com


Rikkert, I added you as a collaborator on the Github repo in case you are interested in the underlying code. Again, this is a Rails site.

from pikaday.

rikkert avatar rikkert commented on June 28, 2024

Great thanks.
Very weird but I can't seem to reproduce it. :|

I edited the post a couple times:
edit -> submit
edit -> click on pikaaday -> submit
edit -> click on pikaaday -> choose 1 jan -> submit
edit -> click on pikaaday -> choose 2 jan -> submit

All of these actions had the expected result: either date was 1 jan or 2 jan.
Should I do something else?

from pikaday.

memoht avatar memoht commented on June 28, 2024

To quote a recent movie. "You had my curiosity. Now you have my attention." I have uploaded a short movie in which I went through various browsers on Mac OS Mountain Lion, Windows XP, Windows 7 and Windows 8. Long story short, I did notice that the problem did not occur in Safari on Windows 7 or 8, but did occur in all other browsers on all platforms.
Here is the video: http://youtu.be/me5XBWPqNzw


  • I don't currently have any Linux OS loaded so could not test that platform. Perhaps you are on Linux?
  • The only other thing I can think of is that I have disabled/uninstalled Oracle Java from my systems due to ongoing security issues with Java. I of course have not disabled JavaScript...

Thanks for taking a look. BTW, I did want to mention that I really like Pikaday. Stopped using JQuery-UI datepicker when I found this little gem. :0) So keep up the great work!

from pikaday.

rikkert avatar rikkert commented on June 28, 2024

Yep, I was on Linux with chrome 26.
Will try again with firefox later.

from pikaday.

memoht avatar memoht commented on June 28, 2024

I loaded up Ubuntu and it seems to do this is Firefox.

from pikaday.

rikkert avatar rikkert commented on June 28, 2024

It is caused by your local (browser) time zone settings.
I put my chromebook from Amsterdam (+1 GMT) to EST and started to see the same problem in chrome.
Could you try with my pull request #42 ? Maybe that fixes it.

Otherwise I can`t really debug your app because it is minimized.

from pikaday.

memoht avatar memoht commented on June 28, 2024

Unfortunately it still goes back. In my Rails app I declare a time zone which I thought helped keep things happy with time based fields since I offset from GMT. I appreciate your effort. My fix was just to load moment.js which is a recommended option anyway so harmless and easy.


If you need me to try anything else let me know.. I will go ahead and close this ticket with this comment. Again, thanks for developing Pikaday, I like that it is lighter and cleaner to use than JQuery datepicker. LLAP.

from pikaday.

rikkert avatar rikkert commented on June 28, 2024

You gave enough info to reproduce the problem. It was only a bit tricky because I had to change my local time-zone.
I found that the problem is the format of the date in your input field. For JavaScript it should be: day month year:
http://tools.ietf.org/html/rfc2822#page-14
Not sure how we can prevent something like this, but it was a fun hunt anyway and thank you!

from pikaday.

alberro avatar alberro commented on June 28, 2024

Hi guys,

We has the same problem and I fixed creating the new Date splitting the date and not using the Date.parse method.

In the setDate method, replace the entire if with:

if (typeof date === 'string') {
    var p = date.split('-');     // We use the format YYYY-MM-DD in our dates.
    date = new Date(p[0], p[1] - 1, p[2]);
}

And that's it, it works perfect without adding Momentjs to your project.

Hope this help,
Greetings.

from pikaday.

TimGeyssens avatar TimGeyssens commented on June 28, 2024

Still having this issue with latest version.. seems to have to do with timezone setting, not sure how to fix any help appreciated

from pikaday.

eybarta avatar eybarta commented on June 28, 2024

I'm also experiencing a similar issue..
I'm using moment() and have been until now no problems..
When adding moment-timezone.js and setting it (e.g: moment.tz.setDefault('America/New_York');) I'm getting the same problem as described above, the display dates for input fields after init is a day back.. Am I doing something wrong or is this a bug? thnx

from pikaday.

sdbondi avatar sdbondi commented on June 28, 2024

Note that when you have a date (like that returned from getDate()) it will have the timezone of your computers clock. When calling date.toUTCString() the date will be in the GMT timezone which may confuse some people into thinking pikaday has chosen the previous day. The call to toUTCString might be transparent to you e.g. an api library might call that method to serialize the date.

.getDate()
Wed Dec 02 2015 00:00:00 GMT+0200 (SAST)

.getDate().toUTCString()
"Tue, 01 Dec 2015 22:00:00 GMT"

This took me a few minutes to realise so I thought I'd put this here in case other are getting confused.

from pikaday.

jacquesporveau avatar jacquesporveau commented on June 28, 2024

This worked for me. In the setDate function of Pikaday.js add:

if (typeof date === 'object') {
  var utc = date.getTime() + (date.getTimezoneOffset() * 60000 + 500);
  date = new Date(utc)
}

I am adding 500 milliseconds because sometimes the calculation is a little off and since my app is saving dates and midnight it would occasionally show the wrong day if the calculation came back slightly short.

from pikaday.

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.