Closed gabskoro closed 11 years ago
in the options try setting forceParse: 0
Maybe that will solve your trouble.
can you give me your html / javascript implementation ? I suggest you to update the lib
I have an input with id="datetimepicker" and javascript code
$("#datetimepicker").datetimepicker({ format: 'dd.mm.yyyy, hh:ii', todayBtn: true, autoclose: true, weekStart: 1, forceParse: 0 });
Now when I add forceParse to 0 the input box don't change but the time goes to today, also i've updated the lib
Can you give me too your html implementation ?
No problem, I am using Ruby on Rails with Haml
= simple_form_for(['admin', @post]) do |f| = f.input :title = f.input :published_at, input_html: {id: "datetimepicker"}, as: "string" = f.input :summary, input_html: {class: "input-rows-summary"} = f.input :content_before_break, input_html: {class: "input-rows-before"} = f.input :content_after_break, input_html: {class: "input-rows-after"} = f.input :tag_list, collection: Post::TAGS, as: :check_boxes, hint: "Please check all that apply" = f.hidden_field :post_status_id = f.button :submit, "Save", class: 'btn btn-success pull-right'
That's quite strange. The format you've specified in the javascript is not according to the data your put in the value attribute of your input date time. Can you try to change it and test again ?
That's because the format in my database is set to datetime, and that's why the date looks like 2012-12-12 21:40:46 UTC...
What I think is that your date-timepicker.js don't check if the input contains any data. It should check for data and if it exists, he should get the value from input and set the value in the view, because now what is does is that he always get's the "now" date and set it in the view.
After initialization call
el.datetimepicker('hide');
it will parse the html tag value.
I've updated the first example of my demo page : (clear you brower cache) http://www.malot.fr/bootstrap-datetimepicker/demo.php I'll change a part of my API to correctly handle the initialization of the picker with the "date" option. However, you can do as on the demo page by setting the value in the same format as the picker's format and set the 'forceParse' to 'true'. Is it ok for you ?
This don't work, I set the format to 'yyyy-mm-dd hh:ii:ss' and still it changes do today if i click on the input box. Than when I set the forceParse to zero and clicking on the input box the value doesn't change but the date again set's to now
Don't know why is this happening because I see that this is working on your demo, you set the value to '2012-06-15 14:45' and when clicking on the input the view shows the date from input.
Sorry to insist, but can you give me your html implementation, the real one, not your ruby code ? I think too that the issue is in your code integration.
I soolved the problem, it was in the UTC text near the date, I just removed the UTC text before writing it in the input box. It would been very nice if your script could detect the UTC text and remove it alone. Anyway thanks for your help :)
your welcome.
When i set a new date and time, save it and then want to edit it, by clicking on the input the time switches to the date of today.
Example:
Yesterday i have set the time to 28.01.2013, 20:00, and saved my post, and today i wanted to change the time do 30.01.2013, 20:00, but wen i edited my post and clicked on the input the time went to 28.01.2013, 00:00
Is this a bug or is there an options that i've missed that corrects this?