Mar 27, 2026 - For details about updated CVE-2025-53521 (BIG-IP APM vulnerability), refer to K000156741.

Forum Discussion

mhite_60883's avatar
mhite_60883
Icon for Cirrocumulus rankCirrocumulus
Dec 09, 2012

Discover timezone via iControl

Hello. Various get_statistics() method calls return timestamps. Is there an iControl API call that will return the timezone that such timestamps are in relation to?

 

Thanks!

 

2 Replies

  • Found what I needed thanks to one of Joe's articles:

     

     

    https://devcentral.f5.com/tech-tips/articles/icontrol-101-19-time-conversions

     

    https://devcentral.f5.com/wiki/iControl.System__SystemInfo__get_time_zone.ashx

     

     

    And this little bit of code is hopefully how one can sanely convert the datetime objects into epoch -- Python makes moving from datetime objects to epoch a slight pain in the arse, unfortunately.

     

     

    
    from datetime import tzinfo, timedelta, datetime
    from pprint import pformat
    
    class TZFixedOffset(tzinfo):
        """Fixed offset in minutes east from UTC."""
    
        def __init__(self, offset, name):
            self.__offset = timedelta(minutes = offset)
            self.__name = name
    
        def utcoffset(self, dt):
            return self.__offset
    
        def tzname(self, dt):
            return self.__name
    
        def dst(self, dt):
            return timedelta(0)
    
    ...
    
        logging.info("Retrieving global IP statistics...")
        ip_stats = b.System.Statistics.get_ip_statistics()
        logging.debug("ip_stats =\n%s" % pformat(ip_stats))
        ts = ip_stats['time_stamp']
        dt = datetime(ts['year'], ts['month'], ts['day'], ts['hour'], ts['minute'], ts['second'], tzinfo=tz)
        logging.debug("dt = %s" % dt)
        timestamp = int((dt - datetime(1970, 1, 1, tzinfo=TZFixedOffset(0, "UTC"))).total_seconds())
        logging.debug("timestamp = %s" % timestamp)
     
  • Need this too:

    
        logging.info("Retrieving time zone information...")
        time_zone = b.System.SystemInfo.get_time_zone()
        logging.debug("time_zone = %s" % pformat(time_zone))
        tz = TZFixedOffset(offset=(time_zone['gmt_offset'] * 60), name=time_zone['time_zone'])