Forum Moderators: coopster

Message Too Old, No Replies

Manipulating a datetime variable into a simple date.

         

Jeremy_H

12:42 am on Jul 14, 2006 (gmt 0)

10+ Year Member



I have a cell in my MySQL table that is a datetime and looks like this: 2006-07-10 15:04:36

Lets say later I grab the value from this cell I assign it to a variable, like $date.

By using the following line of code:

<p>Your last order was on <?php echo($date);?>.</p>

I can output:

"Your last order was on 2006-07-10 15:04:36."

However, I would like to have a sentence that says:

"Your last order was on July 10th."

Is there I way in PHP to easily manipulate "2006-07-10 15:04:36" into "July 10th"?

Thanks

Little_G

12:50 am on Jul 14, 2006 (gmt 0)

10+ Year Member



Hi,

try:

<p>Your last order was on <?php echo date('F jS', strtotime($date));?>.</p>

Andrew

Jeremy_H

1:19 am on Jul 14, 2006 (gmt 0)

10+ Year Member



Completely awesome!

I had no idea there was such an elegant solution.

Works great, thanks so much!

Little_G

9:53 am on Jul 14, 2006 (gmt 0)

10+ Year Member



No problem!

Andrew