在PHP中将特定字符串转换为时间

Dên*_*one 3 php date strtotime

我需要将字符串转换为日期格式,但它返回一个奇怪的错误.字符串是这样的:

21 nov 2012
Run Code Online (Sandbox Code Playgroud)

我用了:

$time = strtotime('d M Y', $string);
Run Code Online (Sandbox Code Playgroud)

PHP返回错误:

Notice:  A non well formed numeric value encountered in index.php on line 11
Run Code Online (Sandbox Code Playgroud)

我在这里错过了什么?

mpe*_*pen 8

你称这个功能完全错了.只是通过它

$time = strtotime('21 nov 2012')
Run Code Online (Sandbox Code Playgroud)

第二个参数用于传入新时间相对于的时间戳.它默认为time().

编辑:这将返回一个unix时间戳.如果您想格式化它,请将新时间戳传递给该date函数.