php strtotime()正确的格式

时间:2015-09-17 04:51:49

标签: php strtotime

如何将其转换为合适的时间戳?

$Year    = "2011";
$Day     = "7";
$Month   = "3";
$Hour    = "3";
$Minutes = "0";
$Seconds = "0";

/// How do I convert to right timestamp?
$dateToTimestamp =  strtotime("$Month $Day $Year $Hour $Minutes $Seconds");

echo "$dateToTimestamp"; // NOT WORKING. Seconds are updating each refresh. 
// They should be static from the var above. 

1 个答案:

答案 0 :(得分:3)

使用mktime

$dateToTimestamp = mktime($Hour, $Minutes, $Seconds, $Month, $Day, $Year);