Q:

PHP - Turn a timestamp (2012-07-12 20:26:00) Into two seperate variables that refelct the month and day values?

I would like to separately strip the day and month values out of this  timestamp "2012-07-12 17:50:00".
So essentially I could have two variables like:
$month = 7
$day = 12

As I am not very proficient with php, specifically regex coding, I thought I would post this question to ask for advice as to how I would go about accomplishing something like this.
Any assistance, insight or input in this regard would be greatly appreciated. Thank you!
AS A NOTE: Futhermore, I would like to turn the two variables into an output like "12th July". This can be coded quite easily so I have not made this a part of the question but if there is a simple function that deals with this information would be much appreciated too!

A:

As said in the comments, DateTime would be a good choice.
First, if your php config dosen't already set it up for you, set your default timezone by:
date_default_timezone_set('XXXX');

XXXX stand for a value out of the List of supported timezones
initialize your date by:
$DateTime = new DateTime();

depending on where you get the timestamp, lets assume you will create it out of PHP:
$timestamp = $DateTime->getTimestamp();

Now format the output
echo $month = $DateTime->format( 'm' );
echo $day = $DateTime->format( 'd' );

or to get you desired output:
echo $output = $DateTime->format( 'dS F' );

A:

<?php
list($month,$day) = explode(':',date('n:j',strtotime('2012-07-12 17:50:00')),2);
echo 'Month: '.$month.'<br />'."\n";//Month: 7
echo 'Day: '.$day.'<br />'."\n";//Day: 12
?>

And...
<?php
echo date('jS F',strtotime('2012-07-12 17:50:00'));//Outputs: 12th July
?>

