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

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!




อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

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



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

Hi,

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

Thanks

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ก.พ. 21
16355
1
ต.ค. 20
3371
Error on TimeZone Field แก้ไขแล้ว
2
ส.ค. 19
3754
0
ก.ย. 16
4320
1
เม.ย. 16
6704