kochier Posted July 5, 2008 Share Posted July 5, 2008 This is the code I am using to display date last modified <?php $file = $_SERVER["SCRIPT_NAME"]; $break = Explode('/', $file); $pfile = $break[count($break) - 1]; //echo $pfile; echo " Last Modified: " .date("m d Y",filemtime($pfile)); ?> And I was wondering if there was any simple way of displaying the date the file was created, I assumed it would be filectime for creation date, but after trying it I found the c stands for changed. Quote Link to comment https://forums.phpfreaks.com/topic/113370-solved-display-date-created-of-a-filename/ Share on other sites More sharing options...
kochier Posted July 5, 2008 Author Share Posted July 5, 2008 Alright well after some research into this I am beginning to wonder if it stores the info for created pages? I have also simplified my code somewhat, as I found the other code needlessly long, though I may be wrong. <?php echo " - " .date("m d Y", filemtime($_SERVER["SCRIPT_FILENAME"])); ?> Is now what I am using to display last modified date, though I still can't figure out the creation date Quote Link to comment https://forums.phpfreaks.com/topic/113370-solved-display-date-created-of-a-filename/#findComment-582534 Share on other sites More sharing options...
Bauer418 Posted July 5, 2008 Share Posted July 5, 2008 Most *nix based systems don't store the created date, which is why PHP doesn't have a simple way of accessing it. Quote Link to comment https://forums.phpfreaks.com/topic/113370-solved-display-date-created-of-a-filename/#findComment-582548 Share on other sites More sharing options...
kochier Posted July 5, 2008 Author Share Posted July 5, 2008 Well is there any simple way of doing it? I was thinking of somehow using a MySQL database, but I haven't touched it yet, and I've had problems getting it to work for me (ie. I have no clue how to use it). Quote Link to comment https://forums.phpfreaks.com/topic/113370-solved-display-date-created-of-a-filename/#findComment-582554 Share on other sites More sharing options...
kochier Posted July 6, 2008 Author Share Posted July 6, 2008 Alright well how would I store the date created in a MySQL database, is there anyway to do it through php, or do I need to enter all of the dates manually? Quote Link to comment https://forums.phpfreaks.com/topic/113370-solved-display-date-created-of-a-filename/#findComment-582635 Share on other sites More sharing options...
DarkWater Posted July 6, 2008 Share Posted July 6, 2008 Yeah, connect to the DB, and use an INSERT query and use the MySQL NOW() function as the data for a DATETIME column. Quote Link to comment https://forums.phpfreaks.com/topic/113370-solved-display-date-created-of-a-filename/#findComment-582639 Share on other sites More sharing options...
kochier Posted July 7, 2008 Author Share Posted July 7, 2008 Can I run a .asp script in a .php file, through using the include function? I know I can do this in .asp (run a php file) but does it work the other way around? Quote Link to comment https://forums.phpfreaks.com/topic/113370-solved-display-date-created-of-a-filename/#findComment-583222 Share on other sites More sharing options...
DarkWater Posted July 7, 2008 Share Posted July 7, 2008 I'm not sure. What does the ASP script do? Maybe you could rewrite it in PHP. Quote Link to comment https://forums.phpfreaks.com/topic/113370-solved-display-date-created-of-a-filename/#findComment-583223 Share on other sites More sharing options...
kochier Posted July 8, 2008 Author Share Posted July 8, 2008 Never mind, figured out about the script, I can include it, but wasn't configured to run .asp on the apache server. So this is what I have so far <?php include 'opendb.php'; mysql_select_db('sitemap') or die('Cannot select database'); include 'closedb.php'; ?> and this is what I want the db to look like: name pathname created (m d Y) map Main index.php 10/24/2007 1 Absurdity absurdity.php 07/02/2008 2 or possibly combine the name and pathname into an href statement if possible (href=index.php Main). Quote Link to comment https://forums.phpfreaks.com/topic/113370-solved-display-date-created-of-a-filename/#findComment-584097 Share on other sites More sharing options...
kochier Posted July 8, 2008 Author Share Posted July 8, 2008 Ok I've tried to insert code and my problem is nothing will show up now: <?php include 'opendb.php'; mysql_select_db('sitemap') or die('Cannot select database'); $sql = "CREATE TABLE map ( Created date, Name varchar, Pathname varchar, Map int )"; mysql_query($sql); mysql_query("INSERT INTO map (Created, Name, Pathname, Map) VALUES ('2007-10-24', 'Main', 'index.php', '1')"); $result = mysql_query("SELECT * FROM map"); echo $result['Map']; include 'closedb.php'; ?> I think it should echo "1" but nothing shows up when I run it. Quote Link to comment https://forums.phpfreaks.com/topic/113370-solved-display-date-created-of-a-filename/#findComment-584173 Share on other sites More sharing options...
vicodin Posted July 8, 2008 Share Posted July 8, 2008 Google how to insert data into using php. Its pretty simple and you dont need the closedb include, it will do it automatically. Quote Link to comment https://forums.phpfreaks.com/topic/113370-solved-display-date-created-of-a-filename/#findComment-584199 Share on other sites More sharing options...
kochier Posted July 8, 2008 Author Share Posted July 8, 2008 I've googled it, and as far as I can tell I'm doing everything right, but it won't display. Quote Link to comment https://forums.phpfreaks.com/topic/113370-solved-display-date-created-of-a-filename/#findComment-584202 Share on other sites More sharing options...
kochier Posted July 8, 2008 Author Share Posted July 8, 2008 <?php include 'opendb.php'; mysql_select_db('sitemap') or die('Cannot select database'); $sql = "CREATE TABLE map ( Created date, Name varchar, Pathname varchar, Map int )" or die ('Cannot create table'); mysql_query($sql) or die('Failure?'); mysql_query("INSERT INTO map (Created, Name, Pathname, Map) VALUES ('2007-10-24', 'Main', 'index.php', '1')") or die('Failure to Insert data'); $result = mysql_query("SELECT * FROM map"); while($map=mysql_fetch_array($rsql)) { echo $map['Map']; } include 'closedb.php'; ?> Is as far as I've gotten now. "Failure?" appears as my error, I can't figure out what's wrong with mysql_query though. Quote Link to comment https://forums.phpfreaks.com/topic/113370-solved-display-date-created-of-a-filename/#findComment-584856 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.