Kangry.com [insert cool graphic here]
home | Topics | Logout | Search | Contact | ?? Kangry ?? | Bandwitdh



New user

uploaded files
(links)-> (Parent)->perl ctime format , stat and time commands submited by Russell Mon 17 Oct 05
Edited Fri 27 Jan 06
Web kangry.com
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks)= stat($name);
Where $name is the full path to the file I want info on.
$atime= last access
$mtime= last modified
$ctime= create time, (not always correct, depends on how file was last opened)

($sec,$min,$hour,$mday,$mon,$myear) = localtime($mtime);
$myear is years since 1900, ( add 1900 to get the 4 digit year)
$mon is the numeric month with ZERO for JANUARY so add one to use it

In practice, here is the code I use (I come here to copy it as needed):

                = stat($name);
@months =('01','02','03','04','05','06','07','08','09','10','11','12');
($sec, $min, $hour,$mday, $mon, $year, $wday, $yday, $isdst) =localtime($mtime);
$typical_date ="$months[$mon]/$days[$mday]/$year";

the months array prefixes a zero, and adds one. The days array is used to add the leading zero where needed. I use this array to do the same thing for hours, minutes and seconds (hence the reason why I list days up 2 60. That could also be done using sprintf("%02d", $number); But for this simple case, This looks cleaner to me.

A small amount of time could be saved moving the arrays definitions to some global location. In practice, this is never the most seriuos bottleneck.
Ctime format:
use Time::localtime;
     $mod_time=ctime($mtime);  ## gives us a string format
     print"$mod_time ( ctime format)\n";
    ## prints "Mon Apr 25 11:58:41 2005"
Is there a way to change this format ??

Add comment or question...:
Submited by: NOT email address. Leave blank for anonymous    (Spam Policy)

Enter Text: (text must match image for posting)

This file (the script that presented the data, not the data itself) , last modified Tuesday 06th of March 2018 11:41:12 PM
your client: CCBot/2.0 (https://commoncrawl.org/faq/)
current time: Saturday 20th of April 2024 10:43:43 PM