I am using datimepicker (from: http://trentrichardson.com/examples/timepicker/) however I cannot save the picket date-time combo to the database. It is ignoring values and always saving it as empty.
I have this on my Application.js file
ok $("#child_dob").datepicker({changeMonth: true, changeYear: true, dateFormat: "dd-mm-yy", altFormat: 'yy-mm-dd' });
notOk $("#announcement_date").datetimepicker({ampm: true, altFormat: 'yy-mm-dd hh:mm:ss', dateFormat: "mm-dd-yy", timeFormat: 'hh:mm tt'});
So the child model on dob field works because it is just the datepicker, however, the announcement model on date with datetimepicker will only save empty. I played around with different “altFormat” and date/time format but without success. I know this can be done as I have used it before but am not sure went wrong now. Any guidance will be greatly appreciated.
Thank you.
Env:
Rails 3.1
JQuery 1.6.2
JQueryUI 1.8.16
OS: Lion
The alt fields only matter if you’re using ‘altField’. You can omit ‘altFormat’ and it should function properly.
You set the ‘altField’ to point to a hidden input to store your date/time value. If you use ‘altField’, you then use ‘altFormat’ to format that hidden time field. If you are using both of those you will want to set ‘altFieldTimeOnly’ to false (it defaults to true).
This should work: