Jump to content


Photo

quick date question


  • Please log in to reply
6 replies to this topic

#1 uknowho008

uknowho008
  • Members
  • PipPipPip
  • Advanced Member
  • 55 posts

Posted 02 May 2006 - 01:53 AM

this is probably a stupid question but how do i format a timestamp that im getting from a database to look like this?

Mon, 1 May 2006 14:41:22 CET


please dont hurt me :D

#2 AndyB

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

Posted 02 May 2006 - 03:09 AM

[a href=\"http://ca.php.net/manual/en/function.date.php\" target=\"_blank\"]http://ca.php.net/manual/en/function.date.php[/a]

Look at the options in the table that determine the precise manner in which the date/time are output. All you need is on that page. The example 4 should really help you.
Legend has it that reading the manual never killed anyone.
My site

#3 uknowho008

uknowho008
  • Members
  • PipPipPip
  • Advanced Member
  • 55 posts

Posted 02 May 2006 - 03:50 AM

thanks but i cant figure out how to use a use a timestamp from the database instead of the current date

if my variable is $post_date

how would i format that?

#4 uknowho008

uknowho008
  • Members
  • PipPipPip
  • Advanced Member
  • 55 posts

Posted 02 May 2006 - 06:30 PM

here is what im using to format the date

$post_date = "20060420201649";


$post_date = date("D, j M Y G:i:s T", $post_date);


and this is what it outputs no matter what the $post_date is

Mon, 18 Jan 2038 22:14:07 EST

what am i doing wrong? i cant figure this out.

#5 kenrbnsn

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

Posted 02 May 2006 - 06:39 PM

The date() function expects to see an integer containing the number of seconds since 1/1/1970, you are passing a string. How are you getting the value into $post_date?

Ken

#6 uknowho008

uknowho008
  • Members
  • PipPipPip
  • Advanced Member
  • 55 posts

Posted 02 May 2006 - 06:43 PM

im getting the value from the database. its set to timestamp. so how can i fix the problem? i dont really understand the seconds since 1/1/1970. thanks for the help.

#7 uknowho008

uknowho008
  • Members
  • PipPipPip
  • Advanced Member
  • 55 posts

Posted 03 May 2006 - 10:47 PM

i know this shouldnt be that difficult. but i cant figure it out. can sombody help me out? paaaleeaasse?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users