Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Jul 2012
    Posts
    7
    Thanks
    0
    Thanked 1 Time in 1 Post

    Last Modified Date

    Hi,

    I have a php page that imports data from a csv file and I would like it to display the date that the csv file was last modified, but it always shows the date uploaded, and I'm afraid that may not always be accurate.

    Is there any way to get the actual modified date, without it changing the last modified date to the date that it was uploaded? The page is supposed to show "current inventory as of last modified date".

    Thanks for any tips or suggestions,

    ginger

  • #2
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    Found this:

    PHP Code:
    <?php
    // outputs e.g.  somefile.csv was last modified: December 29 2002 22:16:23.

    $filename 'somefile.csv';
    if (
    file_exists($filename)) {
        echo 
    "$filename was last modified: " date ("F d Y H:i:s."filemtime($filename));
    }
    ?>
    I would do this and store the value before importing the data.
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS

  • #3
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    There was a bug previously with Windows not determining the correct time (don't know if this was fixed subsequently):

    PHP Code:
    <?php 
    function GetCorrectMTime($filePath


        
    $time filemtime($filePath); 

        
    $isDST = (date('I'$time) == 1); 
        
    $systemDST = (date('I') == 1); 

        
    $adjustment 0

        if(
    $isDST == false && $systemDST == true
            
    $adjustment 3600
        
        else if(
    $isDST == true && $systemDST == false
            
    $adjustment = -3600

        else 
            
    $adjustment 0

        return (
    $time $adjustment); 

    ?>
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS

  • #4
    New to the CF scene
    Join Date
    Jul 2012
    Posts
    7
    Thanks
    0
    Thanked 1 Time in 1 Post
    Quote Originally Posted by AndrewGSW View Post

    I would do this and store the value before importing the data.
    Hi,

    That's what I'm doing, but the last modified date is the date that the file is uploaded to the server rather than the last time the file was changed.

    In case I wasn't clear in my first post, the data file is created in Excel and saved as current-inventory.csv. It's to be updated locally and uploaded to the server once a week. The php page imports the data and outputs to an html table. As long as the file is uploaded as soon as it's updated, it's not a problem.

    Hope that clarifies.

    Thanks,

    ginger

  • #5
    Regular Coder Arcticwarrio's Avatar
    Join Date
    May 2012
    Location
    UK
    Posts
    723
    Thanks
    20
    Thanked 84 Times in 84 Posts
    you could save the current date / time on the first row and parse it?
    There are 10 types of people on CodingForums,
    Those who understand Binary and those who dont.
    Get Cloud Hosting now from only£59 / month

  • #6
    New to the CF scene
    Join Date
    Jul 2012
    Posts
    7
    Thanks
    0
    Thanked 1 Time in 1 Post
    Thanks for the suggestion. That sounds like it might work.

    ginger


  •  

    Posting Permissions

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