from datetime import datetime date = datetime.now().strftime("%Y_%m_%d-%I:%M:%S_%p") print(f"filename_{date}") 'filename_2020_08_12-03:29:22_AM'