Python node for getting Date and Time of files

Hello Dynamo users. I am pretty new in using Python and I I have been stuck with code problem. I try to create node which allows to define the Time of last modification of list of files. I can not process list of files but the node for one file works perfectly. Do you have any advices to solve it?Get%20time

Are there any exceptions or errors? You are using a for loop to access each item in numberList, but you are overwriting the file variable in each iteration.

Should I use file [ x ]= time…? I doesn’t work either.
Theerror is “expected an indented block”

The exact information is here. On the right side workable code on the left not.

import os, time

def getYYMMDD(filepath):	
    statbuf = os.stat(filepath)
    date = time.localtime((statbuf.st_mtime))
    # Debug
    #print str(date)

    # Extract out the year, month and day from the date
    year = date[0]
    month = date[1]
    day = date[2]
    # YY
    strYear = str(year)[2:]
    # MM
    if (month <=9):
        strMonth = '0' + str(month)
        strMonth = str(month)
    # DD
    if (day <=9):
        strDay = '0' + str(day)
        strDay = str(day)
    return (strYear+strMonth+strDay)

files = IN[0]    
newlist = []
for file in files:
OUT = newlist

EDIT: your input is typed in…

Thank you for reply. But it seems that files array is not defined in the code.

can show me the error code?

yes i tested on my end. it works fine?

I tried to use it.

This is mine for one file workable. I need to upgrade it for list of files.

use the new edited code. with files = IN[0]

Thank you it works. The only question is what if I would like to get time as well?

def getYYMMDD(filepath):	
    epoch_datetime = os.path.getmtime(filepath)
    date_time = datetime.fromtimestamp(epoch_datetime)
    return date_time

use this function

I fix it. But wrote it in other way round. Here is the code.
But the thig is that I could not add “0” to numbers 9 and lower for hours, minutes, and seconds. Probably they are not integers for using (hour <=9)?

if (hour <=9):
strHour = ‘0’ + str(hour)
strHour = str(hour)
This does not work
Said unexpected token ‘else’

Finally I wrote workable code
Thanks for help and advices.