| | |
| | | time_str = datetime.datetime.now().strftime("%H:%M:%S") |
| | | return time_str |
| | | |
| | | |
| | | def get_now_time_with_ms_str(): |
| | | now = datetime.datetime.now() |
| | | ms = int(now.microsecond / 1000) |
| | |
| | | m = seconds % 3600 // 60 |
| | | s = seconds % 60 |
| | | return "{0:0>2}:{1:0>2}:{2:0>2}.{3:0>3}".format(h, m, s, ms) |
| | | |
| | | |
| | | def timestamp_format(timestamp, format): |
| | | """ |
| | | 时间戳格式化 |
| | | @param timestamp: |
| | | @param format: |
| | | @return: |
| | | """ |
| | | return datetime.datetime.fromtimestamp(timestamp).strftime(format) |
| | | |
| | | |
| | | # 交易時間的差值 |
| | |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | | print(get_now_time_with_ms_str()) |
| | | print(get_now_time_with_ms_str()) |
| | | print(get_now_time_with_ms_str()) |
| | | time.sleep(0.001) |
| | | print(get_now_time_with_ms_str()) |
| | | print(timestamp_format(1726034271, "%H%M%S")) |