0

I had this JS/jQuery:

$(this).text().replace(/([^\s]+)/, day);    

which took a line like MAR/26/2013 05:00 PM and converted it to 05:00 PM.

But this PHP does not do a proper replacement for some reason:

$time = preg_replace('/([^\s]+)/', '', $dateStr);

Instead I am left with a string containing one space.

I converted all of my code flawlessly up until the aforementioned line. $(this).text() has the same value as $dateStr.

1 Answer 1

1

If your $dateStr will always be in that format and you only want the 5:00pm component, try:

$dateStr= "MAR/26/2013 05:00 PM";
$time = explode(" ", $dateStr);
echo $time[1]." ".$time[2];
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.