problem with time stamp

Discussion in 'Perl Misc' started by davide.papagno@gmail.com, Jul 13, 2006.

  1. Guest

    Hi all.
    I use this command to get the time stamp file output

    $date = ctime(stat($file)->mtime);

    and what I get is:

    Wed Apr 5 16:44:43 2006

    is there a simple way to get only

    Wed Apr 5
    ?

    really thanx all
     
    , Jul 13, 2006
    #1
    1. Advertising

  2. Tony Curtis Guest

    >> On 13 Jul 2006 06:19:23 -0700,
    >> said:


    > Hi all. I use this command to get the time stamp file
    > output


    > $date = ctime(stat($file)->mtime);


    > and what I get is:


    > Wed Apr 5 16:44:43 2006


    > is there a simple way to get only


    > Wed Apr 5 ?


    Look up strftime in "perldoc POSIX".

    hth
    t
     
    Tony Curtis, Jul 13, 2006
    #2
    1. Advertising

  3. Guest

    Yeah Tony, it seems is great

    $now = strftime "%a %b %d", gmtime;
    print "$now\n";

    But I have to get the time stamp of a file $file.
    I don't know how to match strftime and stat function

    Tony Curtis ha scritto:

    > >> On 13 Jul 2006 06:19:23 -0700,
    > >> said:

    >
    > > Hi all. I use this command to get the time stamp file
    > > output

    >
    > > $date = ctime(stat($file)->mtime);

    >
    > > and what I get is:

    >
    > > Wed Apr 5 16:44:43 2006

    >
    > > is there a simple way to get only

    >
    > > Wed Apr 5 ?

    >
    > Look up strftime in "perldoc POSIX".
    >
    > hth
    > t
     
    , Jul 13, 2006
    #3
  4. Tony Curtis Guest

    >> On 13 Jul 2006 07:08:07 -0700,
    >> said:


    > Yeah Tony, it seems is great $now = strftime "%a %b %d",
    > gmtime; print "$now\n";


    > But I have to get the time stamp of a file $file. I
    > don't know how to match strftime and stat function


    Ah well, couldn't give it all away, could I? :)

    localtime()

    hth
    t
     
    Tony Curtis, Jul 13, 2006
    #4
  5. DJ Stunks Guest

    Tony Curtis wrote:
    > >> On 13 Jul 2006 07:08:07 -0700,
    > >> said:

    >
    > > Yeah Tony, it seems is great $now = strftime "%a %b %d",
    > > gmtime; print "$now\n";

    >
    > > But I have to get the time stamp of a file $file. I
    > > don't know how to match strftime and stat function

    >
    > Ah well, couldn't give it all away, could I? :)
    >
    > localtime()


    or use Date::Format instead of POSIX...

    C:\tmp>perl -MDate::Format -e "print time2str '%a %b %d', (stat
    'tmp.txt')[9]"
    Tue Jul 11

    -jp
     
    DJ Stunks, Jul 13, 2006
    #5
  6. wrote:
    >
    > I use this command to get the time stamp file output
    >
    > $date = ctime(stat($file)->mtime);


    According to my ctime(3) man page: "The call ctime(t) is equivalent to
    asctime(localtime(t))." and in perl localtime() in scalar context is the same
    as C's asctime(localtime(t)) so you don't really need ctime there:

    $date = localtime stat( $file )->mtime;


    > and what I get is:
    >
    > Wed Apr 5 16:44:43 2006
    >
    > is there a simple way to get only
    >
    > Wed Apr 5


    $date = substr localtime stat( $file )->mtime, 0, 10;



    John
    --
    use Perl;
    program
    fulfillment
     
    John W. Krahn, Jul 13, 2006
    #6
  7. Guest

    GREAT!!!
    Thanx all!!


    John W. Krahn ha scritto:

    > wrote:
    > >
    > > I use this command to get the time stamp file output
    > >
    > > $date = ctime(stat($file)->mtime);

    >
    > According to my ctime(3) man page: "The call ctime(t) is equivalent to
    > asctime(localtime(t))." and in perl localtime() in scalar context is the same
    > as C's asctime(localtime(t)) so you don't really need ctime there:
    >
    > $date = localtime stat( $file )->mtime;
    >
    >
    > > and what I get is:
    > >
    > > Wed Apr 5 16:44:43 2006
    > >
    > > is there a simple way to get only
    > >
    > > Wed Apr 5

    >
    > $date = substr localtime stat( $file )->mtime, 0, 10;
    >
    >
    >
    > John
    > --
    > use Perl;
    > program
    > fulfillment
     
    , Jul 14, 2006
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ladygrinningsoul

    Modifying a file's time stamp

    ladygrinningsoul, Dec 5, 2004, in forum: Perl
    Replies:
    1
    Views:
    567
    ladygrinningsoul
    Dec 6, 2004
  2. =?Utf-8?B?QmVydA==?=

    Date/Time stamp in SQL

    =?Utf-8?B?QmVydA==?=, Jan 30, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    21,511
    Wardeaux
    Jan 30, 2004
  3. Zean Smith

    Time stamp problem

    Zean Smith, Feb 7, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    351
    Zean Smith
    Feb 7, 2006
  4. srini
    Replies:
    9
    Views:
    11,749
    Beauregard T. Shagnasty
    Apr 14, 2004
  5. BartlebyScrivener

    shutil.copy time stamp errors on win XP

    BartlebyScrivener, Apr 15, 2006, in forum: Python
    Replies:
    2
    Views:
    404
    BartlebyScrivener
    Apr 16, 2006
Loading...

Share This Page