PHP Update script.. filemtime? -
i sort of beginner php , trying make script shows, in file can include on side part of index page, date of last update , plus underneath list of other pages have updated (in order of update). example if last time updated tuesday , edited news , index page say
august 6, 2013 - home page updated. - news headlines updated.
then underneath show other latest updates.. so:
august 6, 2013 - home page updated. - news headlines updated.
august 5, 2013 - staff updated.
august 2, 2013 - home page updated. - forum updated. - join page updated.
i able set limit on how many updates can shown.. had friend had script years ago , remember done through .txt file , chmod txt file have written permissions. updates.php , on every page wanted generate update status include few lines of scripting @ top of file.. plus list page names , wanted show in either txt file or updates file index.php > home page updated... have lost contact him , no way of me finding it. had go , and got:
<?php $pages = array( 'main page' => 'index3.php', 'staff' => 'staff.php', 'news headlines' => 'news.php', ); $list = array(); foreach($pages $page => $file) { $date = filemtime($file); if(!isset($list[$date])) { $list[$date] = array(); } array_push($list[$date], $page); } krsort($list); foreach($list $date => $pages) { echo date('f j, y', $date) . "<br />\n"; foreach($pages $page) { echo "- $page updated<br />\n"; } } ?>
but doesn't work correctly starts new date if update 2 files in same day... anyway wondering if had idea of how make script? in desperate need great.. unsure of how go , have looked everywhere ages ideas... people , hope hear :)
filemtime() return unix timestamp, 2 updates in same day still 2 different timestamps. instead of using date() format date when echo it, format before saving $date variable:
foreach($pages $page => $file) { $date = date('y/m/d', filemtime($file));
then when print out:
echo date('f j, y', strtotime($date)) . "<br />\n";
Comments
Post a Comment