PHP time format, am and pm with periods

前端 未结 4 1385
粉色の甜心
粉色の甜心 2021-01-07 08:15

How could I adjust the php time format to a.m and p.m with the periods included?

date(\'h:i a\');
相关标签:
4条回答
  • 2021-01-07 08:41

    This is not something that is built-in to PHP. You'll have to do it manually.

    It has been an open request for almost four years now.

    0 讨论(0)
  • 2021-01-07 08:47

    There's no straightforward way.

    What I'd do is fetch date("a"), see whether it's am or pm, and then output a.m or p.m accordingly.

    0 讨论(0)
  • 2021-01-07 08:50

    You do it easy with str_replace:

    str_replace(array('am','pm'),array('a.m','p.m'),date('h:i a'));
    

    Hope this helps

    0 讨论(0)
  • 2021-01-07 08:55

    Just use str_replace to replace am with a.m. and pm with p.m.

    0 讨论(0)
提交回复
热议问题