strtotime() 函数需要解释,有人可以解释这条线吗?


Explanation needed with strtotime() function, Can someone explain this line?

我正在一个php文件中观察这段代码,这是一个strtotime函数。 请告诉我以下函数中"-1-1"的含义。

时间($year."-1-1")

strtotime() 将你的时间字符串转换为 Unix 时间戳。

例如:

strtotime("now") returns 1461336078
strtotime("3 October 2005") returns 1128312000
strtotime("+5 hours") returns 1461354078 and so on.

在您的情况下,如果 $year = 2016,您的时间字符串是"2016-1-1"。也就是说,strtotime($year.'-1-1');将返回您在变量中提供的任何年份$year第一天的时间戳,只需将您的年份与"-1-1"连接即可。

它是连接到任何$year末尾的日期的月份和日期。

如果 $year = 2016,则与写入strtotime('2016-1-1');相同