Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
3356 Lượt xem

Hello,


I try to get the time in the user's time zone. Here is my code, generating an error:


user_tz = self.env.user.tz
MyDate = record.x_studio_approved_date_time_exit.user_tz
record['x_studio_time_exit'] = MyDate.strftime("%H:%M")


But it gives me an error... since the ".user_tz" is not supported.


Can you tell me how to solve this?


Thank you!




Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

no, error is

ValueError: : "name 'env' is not defined" while evaluating.


With my code the error is:

ValueError: : "'datetime.datetime' object has no attribute 'user_tz'" while evaluating



Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

Did you tried with env.user.tz without self ?

Thanks

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 2 21
16507
1
thg 10 20
3548
2
thg 8 19
3882
0
thg 9 16
4503
1
thg 4 16
6844