Formatting a Date Stamp on Echo

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • RT

    Formatting a Date Stamp on Echo

    How would I format a timestamp which is used to show when a quote was
    created in a record set.

    This is the echo -
    <?php echo($row_rsquo te['created']); ?>

    I tried doing this -
    <?php echo date('D, m/d/Y',$row_rsquote['created']); ?>

    but all I get is Monday, 01/18/2038.

    Can anyone tell me how I can echo the value in the correct date format ?

    Thanks

  • Pedro Graca

    #2
    Re: Formatting a Date Stamp on Echo

    RT wrote:
    [Please don't send MIME encoded messages. Thank you]
    [color=blue]
    > How would I format a timestamp which is used to show when a quote was
    > created in a record set.
    >
    > This is the echo -
    > <?php echo($row_rsquo te['created']); ?>
    >
    > I tried doing this -
    > <?php echo date('D, m/d/Y',$row_rsquote['created']); ?>
    >
    > but all I get is Monday, 01/18/2038.
    >
    > Can anyone tell me how I can echo the value in the correct date format ?[/color]

    A TIMESTAMP returns from MySQL as, eg, "20040512171115 ".
    You cannot apply that to the PHP date() function (or you can, but the
    results are not what you expect :) ).


    I'd return a UNIX_TIMESTAMP from the database instead:

    select fld1, fld2, UNIX_TIMESTAMP( created) as created, fld4
    from table
    ...


    which returns something that PHP interprets correctly, sparing you the
    trouble to convert the timestamp in PHP.



    --
    USENET would be a better place if everybody read: : mail address :
    http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
    http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
    http://www.expita.com/nomime.html : to 10K bytes :

    Comment

    • Tim Van Wassenhove

      #3
      Re: Formatting a Date Stamp on Echo

      In article <BCC7BD52.150B0 %robertth@comca st.net>, RT wrote:[color=blue]
      > I tried doing this -
      ><?php echo date('D, m/d/Y',$row_rsquote['created']); ?>
      >
      > but all I get is Monday, 01/18/2038.[/color]

      You could also leave the formatting to mysql.
      Lookup the DATE_FORMAT function in the mysql manual for more info...


      --

      Comment

      Working...