TrevorS / bootstrap3-datetimepicker-rails

This gem packages the bootstrap-datetimepicker for the Rails 3.1+ asset pipeline.
MIT License
292 stars 123 forks source link

Saving multiple dynamic datetimepickers into mysql db #44

Closed pablougas closed 8 years ago

pablougas commented 8 years ago

This was a pain in the a**! So I hope this helps someone using cocoon gem in the future!

<script>
$(document).on("mouseover mouseout", ".datetimepicker", function(){
    $(this).datetimepicker({
        format:'YYYY-MM-DD hh:mm:00 a'
    })
});
$('form').submit( function () {
    $('.datetime').each( function() {
        $(this).val(moment(new Date($(this).val())).format("YYYY-MM-DD HH:mm:ss"))
        console.log($(this).val());
    });
})
</script>