Wimsy113 Wimsy113 - 7 months ago 17
Ruby Question

Remove UTC from Datepicker when editing entry

I'm trying to figure out how to remove the UTC from

worked_at
for the date picker that I currently have when I have a
check_in
that is being edited.

here's the code for the
date_picker


$(function() {
$(".datepicker").datepicker({
dateFormat: "yy-mm-dd"
});
});


Choosing the time looks like this:

Choosing time

Editing a check in like this:

Editing a check in

Any help would be greatly appreciated, I just need to change the format for the
edit
not the
new
.

dkp dkp
Answer

worked_at is a datetime field type. For a datetime field, Rails saves date along with time(in UTC) in the db.

When you edit the same attribute in your form, you get the additional TIME (in UTC) info as well.

So, convert DATETIME field type to DATE field.