Results 1 to 6 of 6

Thread: how to edit timestamp entries

  1. #1
    Join Date
    Mar 2007
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question how to edit timestamp entries

    When I submit a new blog entry with the year set to 2006 the index page displays 2007?
    VIEW MY BLOG INDEX

    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

    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:


    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
    blog entry form
    edit_menu
    edit/update blog entries form

    Can someone point me in the right direction please

  2. #2
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    'Cause it is actually 2007 . PHP uses your system clock.
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  3. #3
    Join Date
    Mar 2007
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I tried:
    PHP Code:
    $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....ew_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:

    PHP Code:
    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....index_vege.php
    Last edited by blwow; 05-05-2007 at 08:01 PM.

  4. #4
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Take out the strtotime() function. MySql should use plain strings.
    - Mike

  5. #5
    Join Date
    Mar 2007
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    you saying delete strtotime from here on the update page:
    Code:
    $timestamp = strtotime($month . " " . $date . " " . $year . " " . $time);
    and this on the journal:
    Code:
    $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....ege.php?page=5

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

  6. #6
    Join Date
    Mar 2007
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ok I fixed the months problem..
    I changed this:
    PHP Code:
    <?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 Code:
    <?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..

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •