zoukankan      html  css  js  c++  java
  • python——(time,datetime)

    #!/usr/bin/env python
    # encoding: utf-8
    '''
    Module Description

    Created on Jul 25, 2019
    @author: user
    @change: Jul 25, 2019 user: initialization
    '''
    import time
    import datetime
    # import pandas as pd

    def timestamp_change_to_localtime(timestamp):
    '''

    @param timestamp: 1566443220095(毫秒级时间戳)
    '''
    timeArray = time.localtime(timestamp / 1000)
    local_time = time.strftime("%Y-%m-%d %H:%M", timeArray)

    def str_change_to_date(time_str):
    '''
    @param: time_str: '2019-03-17 11:00:00'
    @return:
    '''
    dd = datetime.datetime.strptime(time_str, "%Y-%m-%d %H:%M:%S")
    print(dd, type(dd))

    def get_time():
    '''

    :return: '2019-08-28-11-16-03'
    '''
    time.strftime('%Y-%m-%d-%H-%M-%S', time.localtime(time.time()))

    def time_subtraction():
    '''

    :return:
    '''
    old_time = datetime.datetime.strptime('2019-08-26', '%Y-%m-%d')
    now_time = datetime.datetime.today()
    interval_days = (now_time - old_time).days

    if __name__ == '__main__':
    pass
  • 相关阅读:
    4.23计算机网络
    CF436F Banners
    CF1467C Three Bags
    LG P3247 [HNOI2016]最小公倍数
    LG P5473 [NOI2019] I 君的探险
    LG P3261 [JLOI2015]城池攻占
    LG P4149 [IOI2011]Race
    LG P3181 [HAOI2016]找相同字符
    SP7258 SUBLEX
    SP1811 LCS
  • 原文地址:https://www.cnblogs.com/ting152/p/12580566.html
Copyright © 2011-2022 走看看