filemtime
-
To get the last modification time of a file in PHP, we use
filemtime. It returns an integer with a timestamp (seconds since Unix epoch).PHP
$timestamp = filemtime('/path/to/foobar'); print $timestamp; //=> 1205621108
Ruby’s
File.mtimemethod accomplishes the same task, only it returns an instance ofTimeinstead of an integer:Ruby
time = File.mtime('/path/to/foobar') p time #=> Sat Mar 15 15:45:08 -0700 2008
If you then need the timestamp (seconds since Unix epoch) as an integer, use the
Time#to_imethod:Ruby
timestamp = time.to_i p timestamp #=> 1205621108
see also
Looking for Rails or PHP web application development, integration, and training?
Rails for PHP is brought to you by Maintainable Software. Get custom web applications and personalized training from the authors of the book and website.

