问题
Is that normal that this line:
echo date("Y-m-d h:m:s a", strtotime('2012-03-18 12:55:00'))
gives me 2012-03-18 12:03:00 pm
Whatever the minutes I enter, I always get 03 minutes... weird.
回答1:
Your date string format should be :
Y-m-d h:i:s a
PHP's documentation has this to say about formatting a local time/date -
i
- Minutes with leading zerosm
- Numeric representation of a month, with leading zeros
What you were seeing as 03
was actually the month - March :)
回答2:
That's because m
in the date function represents months, not minutes. For minutes, you want to use i
:
Y-m-d h:i:s a
回答3:
In PHP's date
function, the code for minutes is i
not m
:
echo date("Y-m-d h:i:s a", strtotime('2012-03-18 12:55:00'))
回答4:
Your "minutes" are actually "months". Use i
as your date code:
echo date("Y-m-d h:i:s a", strtotime('2012-03-18 12:55:00'))
来源:https://stackoverflow.com/questions/9759720/php-strtotime-problems-with-minutes