Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

date stamp called from php

  • 05-01-2002 2: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