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
  • 相关阅读:
    Struts2
    HIbernate缓存
    spring的静态代理和动态代理
    JVM与垃圾回收机制(GC)和类的生命周期
    java开发设计六大基本原则
    数据表链表结构
    HashMap的底层实现
    string与位运算
    log4j和logback
    C#深入类的方法
  • 原文地址:https://www.cnblogs.com/ting152/p/12580566.html
Copyright © 2011-2022 走看看