Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
17917 มุมมอง

How to set the dateformat in datepicker for a portal template? The problem is that now it's set per user so I have problems in the controller converting into a datetime object, because the format is not constant and I don't want to have 100 elifs to guess the date format.

< i-n-p-u-t type="text" name="date_from" class="form-control o_website_form_date" style="max-width: 200px;" required="required"/>

I've tried to add:

$('.datepicker').datepicker({
format: 'dd.mm.yyyy',
});
and a few other things and none of them worked.

What's wrong with this new text field, that posting code from portal qweb templates isn't possible!!!! That's why the input has '-' between letters.

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi Samo,

Try "data-date-format" attribute in the input tag. Maybe it would help.

Ex:

<input type="text" data-date-format="YYYY-MM-DD"/>


อวตาร
ละทิ้ง
ผู้เขียน

Thanks... I was such an idiot. I've tried data-date-format="dd.mm.yyyy" that I found with google and it didn't seem to work. This data-date-format="DD.MM.YYYY" now works.

คำตอบที่ดีที่สุด

For all those who want to input the date:

Class date:
class="input-group date">
type="date" data-date-format="YYYY-MM-DD" name="class_date" id="class_date"
t-attf-class="form-control #{'form-control-sm' if form_small else ''}"
required="required"/>


อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ก.ย. 22
9713
2
พ.ค. 19
7250
2
มี.ค. 17
11073
1
ม.ค. 23
2085
5
ก.พ. 24
24081