美文网首页
获取时间

获取时间

作者: 汤汤汤汤汤雪林 | 来源:发表于2017-03-08 17:06 被阅读0次
    def get_time(self):
            year = datetime.date.today().year
            month = datetime.date.today().month
            firstDayWeekDay, monthRange = calendar.monthrange(year, month)
            start = str(datetime.date(year= year, month= month, day=1))
            end = str(datetime.date(year=year, month=month, day=monthRange))
            return (time.mktime(time.strptime(str(start),'%Y-%m-%d')), 
                    time.mktime(time.strptime(str(end),'%Y-%m-%d')))
    

    获取当月第一天和最后一天的datetime格式以及时间戳格式,参考

    相关文章

      网友评论

          本文标题:获取时间

          本文链接:https://www.haomeiwen.com/subject/ulabgttx.html