MATLAB: Cannot convert dates prior to Jan 1, 1970

convert datesMATLAB

I have been getting this error, not specifically related to any function, but every time I save a file and try to run it. I even created a file with just a comment in it, saved and tried to reopen the file and got this error.
Caught "std::exception" Exception message is: Cannot convert dates prior to Jan 1, 1970
I don't understand what I am doing wrong as I have used Matlab on several other computers with no problems, any help would be greatly appreciated.
Thanks, Jeff

Best Answer

  • There have been bugs for a few versions now where matlab cannot cope with files with modification time outside of a certain range.
    So the first thing to check are the creation time / modification time and last access time of the file you're trying to open. You can do that with your file browser, or if on windows, from matlab:
    filename = 'C:\somewhere\somefile';
    System.IO.File.GetLastWriteTime(filename).ToString
    System.IO.File.GetCreationTime(filename).ToString
    System.IO.File.GetLastAccessTime(filename).ToString
    However, if you've just created the file, I can't see how any of these times could be before 1970, unless your computer clock is wrong.
    Can you show the code you're using to create the file and then open it?