time_funcs.py 文件源码

python
阅读 36 收藏 0 点赞 0 评论 0

项目:threatdetectionservice 作者: flyballlabs 项目源码 文件源码
def utcnow(format="ts"):
    ''' returns time-aware utc datetime object or timestamp of current time/date
        @Param: format  -  defaults to timestamp, provide "dt" for datetime obj '''

    dt = datetime.now(tz=pytz.utc)
    if format == "dt":
        return dt
    else: # timestamp includes millis down to 6th decimal place
        ts = str(dt.timestamp())
        return ts.replace('.', '')

# DEBUG
# print(utcnow())
# print(utcnow("dt"))

# TODO add methods for converting to client local timezone dynamically
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号