You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
460B

  1. # -*- coding: utf-8 -*-
  2. import time
  3. import datetime
  4. YY_MM_DD_HH_MM_SS = "%Y-%m-%d %H:%M:%S"
  5. YMDHMSF = "%Y%m%d%H%M%S%f"
  6. YMDHMS = "%Y%m%d%H%M%S"
  7. def generate_timestamp():
  8. """根据当前时间获取时间戳,返回整数"""
  9. return int(time.time())
  10. def now_date_to_str(fmt=None):
  11. if fmt is None:
  12. fmt = YY_MM_DD_HH_MM_SS
  13. return datetime.datetime.now().strftime(fmt)
  14. # if __name__=="__main__":
  15. # print(now_date_to_str(YMDHMSF))