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

How to convert utc datetime to local?

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

Hello Giezel Esteves,

     You have to use ORM methods to convert the datetime data to Different TZ(Time Zone).

     import pytz
    user_tz = self.env.user.tz or pytz.utc
    local = pytz.timezone(user_tz)
    display_date_result = datetime.strftime(pytz.utc.localize(datetime.strptime(your_date_or_datetime_info,
    DEFAULT_SERVER_DATETIME_FORMAT)).astimezone(local),"%d/%m/%Y %H:%M%S") 

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
3
ก.ค. 23
27274
2
มิ.ย. 22
5810
2
ก.ย. 21
4779
1
พ.ย. 20
8075
2
มี.ค. 19
6201