Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

date stamp called from php

  • 05-01-2002 03:24PM
    #1
    Registered Users, Registered Users 2 Posts: 476 ✭✭


    there has to be a nice way to call the date.

    as in on the site i want it to have last edited on .... Nov 3rd 2002 {anyother reasonable format would do tho} ... and it could be that last time that that file {or another file was updated}


Comments

  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    RTFM

    adam


  • Registered Users, Registered Users 2 Posts: 476 ✭✭Pablo


    merci beacoups


  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    Couldn't find this earlier:

    [PHP]<?
    echo date('y.m.d.H.i.s', filemtime($DOCUMENT_ROOT . $PHP_SELF));
    ?>[/PHP]

    That'll print:
    YY.MM.DD.HH.MM.SS
    

    adam


  • Registered Users, Registered Users 2 Posts: 476 ✭✭Pablo


    Warning: stat failed for (errno=2 - No such file or directory)

    is an error i'm getting , it saying line 9 is the problem one



    for the code

    [php]<?
    // last update

    $newFile=""; // init newFile

    $handle=opendir('.'); // open dir
    while (false!==($file = readdir($handle))) { // read all files in dir
    if ($file != "." && $file != "..") { //only if file is not . or ..
    $fileDate = filemtime($file); // get date from file
    $newDate = filemtime($newFile); // get date from newFile
    if ($newDate < $fileDate) { // if file is newer
    $newFile = $file; // replace newFile with newerfile
    }
    }
    }
    closedir($handle); // close file

    $newDate = filemtime($newFile); // get date from newFile
    $fileModDate = date("d/m/Y",$newDate); // convert date
    Print("$fileModDate"); // print date

    ?>
    [/php]


  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    /* comments inline */


    [php]<?
    // last update

    /* You've initialised $newFile to an empty string here, right? */

    $newFile=""; // init newFile

    $handle=opendir('.'); // open dir
    while (false!==($file = readdir($handle))) { // read all files in dir
    if ($file != "." && $file != "..") { //only if file is not . or ..
    $fileDate = filemtime($file); // get date from file

    /* But here you're trying to stat the file.
    How can you stat an empty string? */

    $newDate = filemtime($newFile); // get date from newFile
    if ($newDate < $fileDate) { // if file is newer
    $newFile = $file; // replace newFile with newerfile
    }
    }
    }
    closedir($handle); // close file

    $newDate = filemtime($newFile); // get date from newFile
    $fileModDate = date("d/m/Y",$newDate); // convert date
    Print("$fileModDate"); // print date

    ?>[/php]


  • Advertisement
Advertisement