Jump to content


Photo

strtotime problem help!


  • Please log in to reply
2 replies to this topic

#1 warpdesign

warpdesign
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 31 August 2006 - 07:52 AM

Hello, I'm having problems using strtotime. I'm pulling dates from a database, the dates are in the format:
YYYY-MM-DD HH:MM:SS

I want to reformat it so it's more user friendly, i.e.
Sun, May 4 2006
4:30 PM

I thought I could do this using strtotime and then reformating the date, but I get a strange number when I convert the string using that. Something like 1156723200...

Do I then need to feed that number to another function? Also how do I convert it back to the original format to write back to the database?


#2 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 31 August 2006 - 08:20 AM

That 1156723200 is a timestamp.
You use it now with the date() function to make the date formatted nicely.

date("d, F jS Y, g:i A", $timestamp);
Will come out nicely, when $timestamp is your number you got from strtotime().
To format it back to your DB format, use date("Y-n-d H:i:s", $timestamp) ($timestamp is that number you got).

Orio.
Think you're smarty?

(Gone until 20 to November)

#3 warpdesign

warpdesign
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 31 August 2006 - 04:29 PM

Perfect. Thank you so much!!  ;D




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users