How to get a date or timestamp of a file in perl.

Once i was trying to get the date when the file is written in perl. I found the following solutions all of them are giving the complete timestamp of the file but i needed only the date.
You can get the timestamp of a file in following ways in perl :

First Method :

$write_secs = (stat($file))[9];
print “file $file updated at “, scalar(localtime($file)), “\n”;

Second Method :
Using standard module File::stat and Time::locatime(bundled with all 5.x perl installations)

use File::stat;
use Time::localtime;
$date_string = ctime(stat($file)->mtime);
print “file $file updated at $date_string\n”;

To get only the data of file I used this solution :

$tm = localtime(stat($path)->mtime);
#get only the data from time object
$date_string = $tm->mday.”-”.(($tm->mon)+1).”-”.(($tm->year)+1900);
print “file $file updated at $date_string\n”;

3 Responses to “How to get a date or timestamp of a file in perl.”

  1. JORGE says:


    CheapTabletsOnline.com. Canadian Health&Care.Special Internet Prices.No prescription online pharmacy.Best quality drugs. No prescription pills. Buy drugs online

    Buy:Accutane.Actos.Synthroid.100% Pure Okinawan Coral Calcium.Zyban.Prednisolone.Retin-A.Valtrex.Petcam (Metacam) Oral Suspension.Nexium.Mega Hoodia.Human Growth Hormone.Arimidex.Lumigan.Prevacid.Zovirax….

  2. DARRYL says:


    CheapTabletsOnline.com. Canadian Health&Care.Special Internet Prices.Best quality drugs.No prescription online pharmacy. Low price drugs. Order pills online

    Buy:Zocor.Female Cialis.Acomplia.Lipothin.Nymphomax.Wellbutrin SR.Seroquel.Benicar.Cozaar.SleepWell.Advair.Ventolin.Lasix.Buspar.Aricept.Prozac.Amoxicillin.Lipitor.Female Pink Viagra.Zetia….

  3. MAURICE says:


    CheapTabletsOnline.Com. Canadian Health&Care.No prescription online pharmacy.Special Internet Prices.Best quality drugs. Online Pharmacy. Buy pills online

    Buy:100% Pure Okinawan Coral Calcium.Valtrex.Actos.Zovirax.Prevacid.Petcam (Metacam) Oral Suspension.Zyban.Nexium.Mega Hoodia.Human Growth Hormone.Synthroid.Prednisolone.Accutane.Retin-A.Arimidex.Lumigan….

Leave a Reply