SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist
    Join Date
    Mar 2003
    Location
    Melbourne, Australia
    Posts
    463
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    problem with dates being read from mysql db, only showing the newest one

    hi guys
    i'm having a bit of a problem displaying a timestamp (bigint) from mysql
    as a date in php
    i want to use gmt + 10 hours to get it to melbourne time

    PHP Code:
    while($row mysql_fetch_array($result)) {
        
    $ts mktime(gmdate("H:i:s M-d-Y"$row['editDate']));
        
    $d date("H:i:s d-M-Y", ($ts 36000));
        echo(
    $d);

    say it loops through ten times or something
    it will write out the same value (the newest date) for each row
    even if they are all different
    but if i write out the timestamp value
    it will write out the different timestamp values

    using unix_timestamp(now()) to update the database

    so the problem is that it seems to only be executing
    that function on the first value in the table
    thanks for any help
    Last edited by dtra; Sep 10, 2003 at 18:51.

  2. #2
    SitePoint Wizard
    Join Date
    Oct 2001
    Location
    Tucson, Arizona
    Posts
    1,858
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The problem is that you're converting your UNIX timestamp to GMT format, then trying to generate a UNIX timestamp from the GMT-formatted date. Well, mktime() takes about 20 arguments (not really ) and it's probably only accepting the hour as its first parameter and forgetting about the rest.

    But your logic is a bit circular, if I may say so. Why convert from a UNIX timestamp to something else, only to convert back to a UNIX timestamp? You've got the UNIX timestamp from the beginning, so you might as well make good use of it!

    Try this instead:
    PHP Code:
    while ($row mysql_fetch_array($result))
    {
        echo 
    date('H:i:s d-M-Y'$row['editDate']+36000);


  3. #3
    SitePoint Evangelist
    Join Date
    Mar 2003
    Location
    Melbourne, Australia
    Posts
    463
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    cool
    i think that's worked
    thanks for the pointer


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
  •