Comments (18)
For anyone using Ruby/Rails, I found that adding .strftime("%a %b %d %Y")
to a Date fixed the issue.
from pikaday.
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.
Difficult to say what's going on here, doesn't look like you're doing anything wrong. Can you upload an example?
from pikaday.
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.
Could you indeed please host it, I would like to have a look myself.
from pikaday.
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.
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.
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.
Yep, I was on Linux with chrome 26.
Will try again with firefox later.
from pikaday.
I loaded up Ubuntu and it seems to do this is Firefox.
from pikaday.
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.
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.
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.
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.
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.
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.
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.
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)
- Confused about cursor behavior on month area
- How to close on scroll? (Edited)
- Deselect Day if click on selected day?
- Project Status HOT 2
- Backspace clears out the whole input HOT 4
- Missing styles in scss file for .pika-row.pick-whole-week:hover
- Default value of input doesn't show HOT 1
- Change background color of days HOT 1
- arrow keys replace in RTL
- setDate() fire onSelect event when preventOnSelect is true HOT 2
- License clarification
- PLUGIN DOESN'T WORK - pickaday right-hand side of instanceof is not an object HOT 1
- On click or on focus the date picker goes hidden suddenly after that's popped up
- Suddenly the calendar opened on click is on November 1899 HOT 1
- Undesirable scrolling to input element after select year or month HOT 2
- Datepicker with a word before date pick
- Dates in the date-picker are getting disabled after calling the gotoDate function on it
- Problem with choice of month and year on Safari browser on iPhone 12
- Uncaught ReferenceError: Pikaday is not defined for Livewire version 3.0
- If showTime is true, ' HH:mm:ss' is appended to the format even if opts.format is not null. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pikaday.