SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Jun 2006
    Location
    Australia
    Posts
    186
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Perl - julian date

    3 years I did some simple Perl at work and then stopped but need to do more.
    The files I am looking at have a time/date stamp and I need to go backward for x days, gather the entries, manipulate etc:
    I thought that if I get the julian date (j1) of the current date using $yday, subtract x to get a lower julian date (j2) bound then convert the julian back into dd/mm/yyyy. I would then search between the equivalents of j1 & j2.

    The problem is to go from j2 into dd/mm/yyy. I cannot see to locate a function that is the reverse of $yday.
    Does such a function exist?

    (PS: I noted this thread http://www.sitepoint.com/forums/showthread.php?t=483502 which actually seems to do what I require but I'll ask my original question anyway.)
    ========================
    Carn the Tiges!
    www.petalsandpatches.com

  2. #2
    Web development Company chrisranjana's Avatar
    Join Date
    Jan 2001
    Location
    chennai , tamil nadu , India
    Posts
    706
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Chris, Programmer/Developer, Chrisranjana.com
    Chennai, Tamil Nadu, India.
    Php Developers

  3. #3
    SitePoint Wizard bronze trophy KevinR's Avatar
    Join Date
    Nov 2004
    Location
    Moon Base Alpha
    Posts
    1,053
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  4. #4
    SitePoint Zealot
    Join Date
    Jun 2006
    Location
    Australia
    Posts
    186
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wonderful!
    Thank you.
    ========================
    Carn the Tiges!
    www.petalsandpatches.com

  5. #5
    SitePoint Wizard bronze trophy KevinR's Avatar
    Join Date
    Nov 2004
    Location
    Moon Base Alpha
    Posts
    1,053
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You really shouldn't need to do any date conversions to do what you are trying to do. Get the modified date of the file and just subtract that many days (in seconds) from the modified date.

    my $modified_date = (stat 'somefile.txt')[9];
    my $date = $date - (86400 * 30);

    then use $date to find files you are looking for.

    86400 is the number of seconds in a day, so 86400 * 30 is 30 days ago.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •