Log in

View Full Version : how to edit timestamp entries



blwow
05-04-2007, 10:48 PM
When I submit a new blog entry with the year set to 2006 the index page displays 2007?
VIEW MY BLOG INDEX (http://www.webdesignhull.lincoln.ac.uk/jecgardner/blog_test2/index.php)

When I edit the new entry using my update form and I try changing the date again the date vanishes from the index page and it also moves to the last page
VIEW LAST PAGE (http://www.webdesignhull.lincoln.ac.uk/jecgardner/blog_test2/index.php?page=4)

To get to the edit/update entry form I click on a edit_menu.php page which then gives me a list of entries.. On this edit_menu page the dates of the entries are wrong aswel they show this:

Tuesday January 19 2038 -- test
Tuesday January 19 2038 -- dfafddaf
Thursday January 01 1970 -- test 89
Thursday January 01 1970 -- new entry
Thursday January 01 1970 -- test 3
Thursday January 01 1970 -- hehehe yes!!!
Thursday January 01 1970 -- Bold, Italic, Underl...
Thursday January 01 1970 -- Missions
Thursday January 01 1970 -- Improving
Thursday January 01 1970 -- Tasks
Thursday January 01 1970 -- Portfolio PHP blog!

Why are my blog dates like this?

In Dreamweaver this is what my blog table looks like when using view data:
http://www.webdesignhull.lincoln.ac.uk/jecgardner/blog_test2/images/view_date-01.gif

As you can see the timestamp says 00000000000 for all of them apart from the last 2 new entries. How can I change the 000000000 to the correct dates when I entered these into my blog?

I have uploaded the relevant PHPS files here:
index.phps (http://www.webdesignhull.lincoln.ac.uk/jecgardner/blog_test2/index.phps)
blog entry form (http://www.webdesignhull.lincoln.ac.uk/jecgardner/blog_test2/entry/uploader.phps)
edit_menu (http://www.webdesignhull.lincoln.ac.uk/jecgardner/blog_test2/entry/edit_menu.phps)
edit/update blog entries form (http://www.webdesignhull.lincoln.ac.uk/jecgardner/blog_test2/entry/update.phps)

Can someone point me in the right direction please

tech_support
05-05-2007, 06:24 AM
'Cause it is actually 2007 :). PHP uses your system clock.

blwow
05-05-2007, 06:53 PM
I tried:

$newdate = strtotime('October 31 2006');
mysql_query("UPDATE `php_blog` SET `timestamp` = '$newdate' WHERE `id`='1'");

Browser:

Can't modify the column 'timestamp' to the table 'php_blog' in the database.

Query was empty

My posts have an ID and a Record field. The link below is a screenshot of the blog table showing the entires and fields:
http://www.webdesignhull.lincoln.ac.uk/jecgardner/blog_test2/images/view_date-01.gif

The ID field lists the entries in this order:
1, 2, 88, 89, 7, 33, 32, 62, 85, 90, 92.

I want to reset the blog but before I do this I need to know how to change the 0000000 entries to their original date so I can then reset, re-enter entries and then edit dates.

I tried:


mysql_query("UPDATE php_blog SET timestamp='".time(October 31 2006)."' WHERE id='1");

The browser responded with an error from the query:
Parse error: parse error, unexpected T_LNUMBER in /blog/entry/update_timestamp.php on line 6

In this query I am trying to change ID 1 to October 31 2006.

ID 1 on the index page is titled "Portfolio PHP blog!" and next to "Leave a comment" should be the date like the entries above. When you rollover "Leave a comment" the URL says "ID=1". When you click on leave a comment the next page says "Posted on Thursday January 01 1970".. I need to change this to October 31 2006

URLfor the index page:
http://www.webdesignhull.lincoln.ac.uk/jecgardner/blog_test2/index_vege.php

mburt
05-05-2007, 07:25 PM
Take out the strtotime() function. MySql should use plain strings.

blwow
05-05-2007, 08:00 PM
you saying delete strtotime from here on the update page:
$timestamp = strtotime($month . " " . $date . " " . $year . " " . $time);

and this on the journal:

$commenttimestamp = strtotime("now");

I removed - between date and time on the update page:
$timestamp = "$year-$month-$date $time";

I can now change the days and years successfully using the update entry form. Only one problem left and that is the months..All the options in the drop down menu on the update page say January.

This is the code being used:
<select name="month" id="month">
<?php
for ($i=1;$i<13;$i++) {
$checked = ($i==$row['old_month'])? " selected='selected' " :"";
echo "<option $checked; value='$i'>".date('F','2007-'.$i.'-12')."</option>";
}
?>
</select>

Only ideas why it just lists January?

When I submit a new blog entry with this timestamp: February 21 2006 the entry on the index is 00000000..

You can see the entry titled "February 21 2006" on page 5 with no date:
http://www.webdesignhull.lincoln.ac.uk/jecgardner/blog_test2/index_vege.php?page=5

Here is a link to the blog entry form PHPS:
http://www.webdesignhull.lincoln.ac.uk/jecgardner/blog_test2/entry/uploader.phps

blwow
05-06-2007, 08:30 AM
Ok I fixed the months problem..
I changed this:

<?php
for ($i=1;$i<13;$i++) {
$checked = ($i==$row['old_month'])? " selected='selected' " :"";
echo "<option $checked; value='$i'>".date('F','2006-'.$i.'-12')."</option>";

}
?>

too:

<?php
for ($i=1;$i<13;$i++) {
$checked = ($i==$row['old_month'])? " selected='selected' " :"";
echo "<option $checked; value='$i'>".date('F',mktime(0,0,0,$i,12,2006))."</option>";

}
?>

Months work perfectly now :)

I am still trying to figure out how to fix the comments problem..