Title: jQuery strip part of dynamic text, then format to date with PHP
Tags: php;jquery;regex;date;strtotime
Question: I want to strip out everything before the first "- " and everything after the " -" so I am left with "Dec 25, 2011" below (dates are dynamic so it always wont be Dec 25, 2011).  I need to have a Javascript variable first:
Here is the html:
<p class="review-rating"&gt;
By oakbarrels
- Dec 25, 2011
Something.com
</p&gt;
Here is the javascript variable I want to strip out "Dec 25, 2011":
var thedate = $(this).find('.review-rating').html();
With "Dec 25, 2011" in a variable I would like to now use pHp strtotime to format it to "12/25/2011".
Comment: That would be fine, but I am throwing into a MYSQL database, thought it would be easier using php.  The Date is dynamic.

Comment: Why do you want to use PHP? You can reformat the date with JavaScript...

Comment: Then please edit your question to include that information, including the code you're using to retrieve the date from JS and pass into PHP via ajax.

Here is the accepted answer: To get the date string with Javascript, you can do something like this in jQuery:
$('.review-rating').text().match(/\-\s([^\n]+)/)[1].trim();
You can see a jsFiddle of this here: http://jsfiddle.net/w2HvA/
Once this date string is passed to PHP you can use the following to format it.
echo date("d/n/Y", strtotime($theDateString));
Comment for this answer: I've modified my answer to reflect the new question.

Here is another answer: Try this snippet:
<?php
$atr = '<p class="review-rating"&gt;
By oakbarrels
- Dec 25, 2011
Something.com
</p&gt;';
preg_match('/-([^\-&gt;]+)-/mis',$atr,$m);
$dateStr = trim($m[1]);
echo date('Y-m-d',strtotime($dateStr));
Using jQuery:
var thedate = $('.review-rating').html();
alert(thedate.split('-')[1])

Here is another answer: You could do a simple explode to start, so something like this:
$str = "Your HTML here <p class='review-rating'&gt;....</p&gt;";
$array = explode($str,'-');
$date = trim($array[1]);
$timestamp = strtotime($date);
$reformatedDate = date("d/n/Y",$timestamp);
You will def need to clean it up and make sure it works, but this should give you the general idea.
I hope this helps.

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 3, 'CommentCount': 3, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2012:00:02/25/12', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<php><jquery><regex><date><strtotime>', 'Title': 'jQuery strip part of dynamic text, then format to date with PHP', 'ViewCount': 182, 'id': 9446192, 'user_AboutMe': '', 'user_AccountId': 249551.0, 'user_DisplayName': 'ToddN', 'user_Reputation': 2879.0, 'user_Views': 309.0, 'user_id': 525706.0}}