datetime_utils.py 547 B

12345678910111213141516171819202122232425
  1. # -*- coding: utf-8 -*-
  2. # @Time : 2022/12/1 14:14
  3. # @Author : XuJiakai
  4. # @File : datetime_utils
  5. # @Software: PyCharm
  6. import time
  7. import datetime
  8. def get_ds():
  9. return time.strftime("%Y%m%d")
  10. def get_now():
  11. return datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
  12. def datetime_format_transform(datetime_str: str, source_format: str, target_format: str):
  13. middle = datetime.datetime.strptime(datetime_str, source_format)
  14. return datetime.datetime.strftime(middle, target_format)
  15. pass
  16. if __name__ == '__main__':
  17. pass