Formatting a Date in PHP

I have a variable I am returning from a MySQLI Select Statement. It is being loaded into an Associative Array and I would like to format the display of that date.

The variable is $rsNotShowing[‘lastmodified’];

I have tried numerous ways to set the date format but have not had any luck on getting the right display without actually changing the date to the current date. I want the value of the date to stay as the database value but be displayed as M d, Y

Could someone please give me a suggestion? This has driven me batty for a couple days now.

Thank you.


echo date(“M d, Y”, strtotime($rsNotShowing[‘lastmodified’]));

Thank you very much Steve, that worked perfectly.

I am glad that I asked, based on your response I am pretty certain that I would not have figured that one out.

I had tried a bunch of variations of the date function but had no idea I needed to use the strtotime function also.

Thank you again…

No prob. When in doubt, check - there are many useful examples in the comments of the function pages… you’ll usually find several ways to do what your’e looking for…

PHP: date - Manual

If you look at the docs for [fphp]date[/fphp] you see that the second (optional) argument is an integer timestamp. So you just needed to convert the string from mysql into a timestamp.