0

I have following code

$date = '2013-05-11 07:10:14';

echo date('F j, Y at h:i a', strtotime($date); //Not work;  May 11, 2013 at 7:10 am

echo date('F j, Y h:i a', strtotime($date); // This will work when avoiding the `at` from date function.

I am trying to append string in date function to display the above date as May 11, 2013 at 7:10 am. How to make date at this format using prebuilt date function?

2 Answers 2

1

Try escaping the at string,

echo date('F j, Y \a\t h:i a', strtotime($date));

DEMO.

Sign up to request clarification or add additional context in comments.

Comments

1

You need to escape any letters that are also formatting queues. You have to double escape the "t" because \t is the tab character.

echo date('F j, Y \a\\t h:i a');

See it in action

1 Comment

Without additional escape the code is working. i.e F j, Y \a\t h:i a

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.