콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
3662 화면

Hi,

my goal is to display a datetime in the format hours:minutes in a tree view.

I first tried to format my datetime directly in the XML but without success.

Then, I decided to create a new field in my model :

heure_debut = fields.Char(string="Test"compute="_compute_jour")


I defined its value in the following function :

@api.depends('start_date')
    def _compute_jour(self):
        for meeting in self:
            if meeting.start:
                meeting.heure_debut = meeting.start.time().strftime("%H:%M")


The problem I have is that the string has a difference of one hour with the datetime

For example I have this :

Datetime                                    Test

22/02/2021 01:00:00                  00:00

22/02/2021 04:00:00                 03:00   


I think it comes from the timezone but I don't understand how I can include the timezone in the code to obtain the correct string. I could just add an hour to the datetime but I think I will have problems with the time change.


Thank you

아바타
취소
관련 게시물 답글 화면 활동
3
7월 21
5693
3
1월 25
3341
1
2월 21
9426
Time & Date Issue 해결 완료
6
9월 19
10564
2
3월 16
7398