Professional Web Applications Themes

MySQL timestamp to desired date function - PHP Development

Hi all, I have a a timestamp in a DB (14 digits) that I want to display like I want in my pages. I tried to use strtotime, mktime and date functions with no success... it always return the current timestamp instead of the one I have stored. This is what I've done so far: for ($x = 0; $x < $num_rows; $x++) { $row = mysql_fetch_array($result); $date1 = strtotime($row[lugar_lastinsert]); $date2 = date("d \de m \de Y \a \l\a\s H:i:s", mktime($date1)); echo "<tr>"; echo "<td>"; echo $row[lugar_name]." - ".$row[lugar_specific]; echo "</td>"; echo "<td align=\"center\">"; echo $date2; echo "</td>"; echo "</tr>"; ...

  1. #1

    Default MySQL timestamp to desired date function

    Hi all,

    I have a a timestamp in a DB (14 digits) that I want to display like I
    want in my pages. I tried to use strtotime, mktime and date functions
    with no success... it always return the current timestamp instead of the
    one I have stored. This is what I've done so far:

    for ($x = 0; $x < $num_rows; $x++)
    {
    $row = mysql_fetch_array($result);
    $date1 = strtotime($row[lugar_lastinsert]);
    $date2 = date("d \de m \de Y \a \l\a\s H:i:s",
    mktime($date1));
    echo "<tr>";
    echo "<td>";
    echo $row[lugar_name]." - ".$row[lugar_specific];
    echo "</td>";
    echo "<td align=\"center\">";
    echo $date2;
    echo "</td>";
    echo "</tr>";
    }

    How can I do this and make it work?

    Thanks in advanced,

    Cesar Aracena
    [url]www.icaam.com.ar[/url]
    Cesar Aracena Guest

  2. #2

    Default Re: [PHP] MySQL timestamp to desired date function

    Hi,

    Thursday, September 18, 2003, 2:38:50 PM, you wrote:
    CA> Hi all,

    CA> I have a a timestamp in a DB (14 digits) that I want to display like I
    CA> want in my pages. I tried to use strtotime, mktime and date functions
    CA> with no success... it always return the current timestamp instead of the
    CA> one I have stored. This is what I've done so far:

    CA> for ($x = 0; $x < $num_rows; $x++)
    CA> {
    CA> $row = mysql_fetch_array($result);
    CA> $date1 = strtotime($row[lugar_lastinsert]);
    CA> $date2 = date("d \de m \de Y \a \l\a\s H:i:s",
    CA> mktime($date1));
    CA> echo "<tr>";
    CA> echo "<td>";
    CA> echo $row[lugar_name]." - ".$row[lugar_specific];
    CA> echo "</td>";
    CA> echo "<td align=\"center\">";
    CA> echo $date2;
    CA> echo "</td>";
    CA> echo "</tr>";
    CA> }

    CA> How can I do this and make it work?

    CA> Thanks in advanced,

    CA> Cesar Aracena
    CA> [url]www.icaam.com.ar[/url]


    strtotime() returns a timestamp so you don't need the mktime() call

    $date2 = date("d \de m \de Y \a \l\a\s H:i:s", $date1);
    --
    regards,
    Tom
    Tom Rogers Guest

  3. #3

    Default Re: MySQL timestamp to desired date function

    In article <001001c37d9e$c8d78c60$0300a8c0notebook>, [email]listsicaam.com.ar[/email]
    says...
    > Hi all,
    >
    > I have a a timestamp in a DB (14 digits) that I want to display like I
    > want in my pages. I tried to use strtotime, mktime and date functions
    > with no success... it always return the current timestamp instead of the
    > one I have stored. This is what I've done so far:
    >
    > for ($x = 0; $x < $num_rows; $x++)
    > {
    > $row = mysql_fetch_array($result);
    > $date1 = strtotime($row[lugar_lastinsert]);
    > $date2 = date("d \de m \de Y \a \l\a\s H:i:s",
    > mktime($date1));
    > echo "<tr>";
    > echo "<td>";
    > echo $row[lugar_name]." - ".$row[lugar_specific];
    > echo "</td>";
    > echo "<td align=\"center\">";
    > echo $date2;
    > echo "</td>";
    > echo "</tr>";
    > }
    >
    > How can I do this and make it work?
    >
    > Thanks in advanced,
    >
    > Cesar Aracena
    > [url]www.icaam.com.ar[/url]
    >
    Have you considered using MySQL's DATE_FORMAT function?

    Cheers
    --
    Quod subigo farinam

    A: Because it messes up the order in which people normally read text.
    Q: Why is top-posting such a bad thing?
    A: Top-posting.
    Q: What is the most annoying thing on usenet?
    David Robley Guest

Similar Threads

  1. Replies: 1
    Last Post: October 24th, 11:38 AM
  2. timestamp to date ?
    By Damian John Paul Brown in forum PHP Development
    Replies: 3
    Last Post: April 11th, 07:31 AM
  3. mysql date to timestamp
    By Ben in forum PHP Development
    Replies: 2
    Last Post: December 8th, 05:22 PM
  4. [PHP] MySQL timestamp to desired date function
    By Cesar Aracena in forum PHP Development
    Replies: 0
    Last Post: September 18th, 05:12 AM
  5. Date/Time and TIMESTAMP
    By guiksye webforumsuser@macromedia.com in forum Macromedia Director Lingo
    Replies: 2
    Last Post: July 17th, 03:51 PM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139