Jump to content


Photo

Date Display


  • Please log in to reply
3 replies to this topic

#1 mcmuney

mcmuney
  • Members
  • PipPipPip
  • Advanced Member
  • 358 posts

Posted 15 September 2006 - 09:05 PM

I'm sure this is very simple, but confusing to me.. how to display date in various formats. My database stores date as "1158340157" and when i display with this code
<?=$rs_mem[$i][date_added]?>

How and where do I specify the format of this?

#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 15 September 2006 - 09:18 PM

How was 1158340157 generated in the first place?
Legend has it that reading the manual never killed anyone.
My site

#3 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 15 September 2006 - 11:42 PM

That looks like a UNIX timestamp. To convert it into something readable, use the date() function.

<?php
$nd = 1158340157;
echo date('Y-m-d',$nd);
?>

Ken

#4 pkSML

pkSML
  • Members
  • PipPipPip
  • Advanced Member
  • 191 posts
  • LocationBucyrus, Ohio

Posted 16 September 2006 - 01:07 AM

If you'd like to display MM-DD-YYYY at HH:MM:SS, try this code:

<?php
echo date("m-d-Y \a\\t H:i:s",$rs_mem[$i][date_added]);
?>
code]

-Stephen

Need a LitlURL?

Got code to share? --> The Code-Bin




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users