mysql - Format php datetime as "Wednesday, April 16, 2014 at 2:24 PM"

181

I have this this datetime stored in db: 2014-04-16 14:24:24

I'd like to format it to: Wednesday, April 16, 2014 at 2:24 PM

with this script: date("l, F d, Y \a\t g:i A", strtotime($list['publish_time']))

But it comes out as: Wednesday, April 16, 2014 a 2:24 PM

It seems the "t" in "at" is not escaping properly. Am I doing anything wrong? Please help, thanks in advance!!

424

Answer

Solution:

You need to use single quotes:

date('l, F d, Y \a\t g:i A', strtotime($list['publish_time']))

\t in double-quotes (date("\t")) is first parsed as tab character, thus the actual letter is missing.

People are also looking for solutions to the problem: php - Undefined function is working at second click (with an error)

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.