Skip to content
Advertisement

Add date object in a relative path?

I’m currently trying to create PDF from Excel file in Python, with the hour and date of creation of the PDF on the name’s file. But I’m stuck with the relative path:

JavaScript

How could I add a date object in my relative path? Just below part of my code.

JavaScript

Advertisement

Answer

Based on your comment I’ll try to make an answer:

You have the following as the formating: now.strftime("%d/%m/%Y-%H:%M:%S") This would, as of right now, produce the string “14/01/2022-10:50:46”. But windows does not allow slashes nor colons in file names. So you would have to find another date format. Maybe something like now.strftime("%d%m%Y %H-%M-%S"), which will get you “14012022 10-50-46”.

Or, to make it more sortable: now.strftime("%Y%m%d %H-%M-%S") for “20220114 10-50-46”

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement