[Python] python get time stamp on file in mm/dd/yyyy-HH:MM format

Discussão em 'Python' iniciado por Stack, Julho 13, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to get the datestamp on the file in mm-dd-yyyy-hh:mm format.

    time.ctime(os.path.getmtime(file))


    gives me detailed time stamp:

    Fri Jun 07 16:54:31 2013


    How can I display the output as:

    06-07-2013-16:54


    This is very similar to: python get time stamp on file in mm/dd/yyyy format

    This is doing the half of what I want but I can't add hour and minute.

    time.strftime('%m/%d/%Y', time.gmtime(os.path.getmtime(file)))

    Continue reading...

Compartilhe esta Página