Computing.Net > Forums > Unix > retreive the date with the time --URGENT

retreive the date with the time --URGENT

Reply to Message Icon

Original Message
Name: Rebekah
Date: February 26, 2002 at 01:04:10 Pacific
Subject: retreive the date with the time --URGENT
Comment:

Hi,

I want to retrieve the last modified date (with the time) of a file.Can you kindly help me out with the Unix command.

thx
Rebekah


Report Offensive Message For Removal


Response Number 1
Name: stefancaunter
Date: February 26, 2002 at 20:41:10 Pacific
Subject: retreive the date with the time --URGENT
Reply: (edit)

the best thing to do is use perl's stat function

#!/usr/bin/perl -w
@file_info = stat("../../rel/path/to/file");
$time = time;
#calculate the difference in seconds
$diff_sec = ($time - $file_info[9]);

make this an executable script and it will give you the exact time difference between now and the last modified time in seconds.
you can perform basic math to get days, hours, etc.

Hope that helps.
Let me know if you need more help.

S


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: retreive the date with the time --URGENT

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




How often do you use Computing.Net?

Every Day
Once a Week
Once a Month
This Is My First Time!


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge