You probably need to prefix the directory with "..\\" or possibly fully qualify the directory name from the root. Alternatively, you may need to further escape the prefix text depending on your OS. It looked like a DOS-like message, so I used that syntax.
The message you received as the error is exactly the behavior of being in the directory and issuing a DIR MYDIR command, where MYDIR is the name of your directory.
Other possible solutions include:
$datetime=ftp->mdtm(".");
$datetime=ftp->mdtm("../$directory");
$datetime=ftp->mdtm("..\\$directory");
Sometimes you will run into a situation where a period (.) needs to be escaped, but that is in regular expressions. So if you need to build a variable using regular expressions then it may be required to escape those special characters so they will function as literals.
You may also need to explicitly set your directory with a CD command (ftp->cd) if you are using relative directory names.
Gurydian