我正在观察这个代码,它是一个strtotime函数的php文件。请在下面的函数中告诉我'-1-1'的含义。strtotime()函数需要解释,有人可以解释这一行吗?
的strtotime($一年。 '-1-1')
我正在观察这个代码,它是一个strtotime函数的php文件。请在下面的函数中告诉我'-1-1'的含义。strtotime()函数需要解释,有人可以解释这一行吗?
的strtotime($一年。 '-1-1')
strtotime()将您的字符串转换为Unix时间戳。
如:
strtotime("now") returns 1461336078
strtotime("3 October 2005") returns 1128312000
strtotime("+5 hours") returns 1461354078 and so on.
在你的情况,你的时间字符串为“2016年1月1日”,如果$一年= 2016也就是说,的strtotime($一年。' - 1 1' );将返回您在$ year变量中提供的任何一年中第一天的时间戳,方法是将您的年份与“-1-1”简单地连接起来。
谢谢。我希望我能够升级它。这真的很有帮助。自一小时以来我一直困在这里。 –
它串接到的任何$一年的结束日期的月份和日期..
如果$一年= 2016年,它的与写作一样strtotime('2016-1-1');
当你想得到什么结果? – Naumov
将是文字 - ... Jan/01,例如,如果年份为2016,则将返回01/01/2016的时间戳 – cmnardi
使用strtotime()函数处理日期。阅读http://php.net/manual/en/function.strtotime.php – sAcH