我正在寻找将这行代码转换为PHP的mktime():

Calendar timeStartPoint = Calendar.getInstance();

timeStartPoint.set(11, 0);
timeStartPoint.set(12, 0);
timeStartPoint.set(13, 0);
timeStartPoint.set(14, 0);
timeStartPoint.set(5, monthStartPoint ? 1 : 5);
timeStartPoint.set(2, 0);
timeStartPoint.set(1, 2004);


我想象1是年份,5是某种类型的月份,其余的我不确定。我在网上四处张望,并设法找到java.util.calendar.set(x,x)的文档,但是它们均未列出恶魔整数名称。

最佳答案

常量的含义如下:

Calendar timeStartPoint = Calendar.getInstance();

timeStartPoint.set(11, 0); // hour of day
timeStartPoint.set(12, 0); // minute
timeStartPoint.set(13, 0); // second
timeStartPoint.set(14, 0); // millisecond
timeStartPoint.set(5, monthStartPoint ? 1 : 5); // day of month
timeStartPoint.set(2, 0); // month (zero-based!)
timeStartPoint.set(1, 2004); // year


我不精通PHP,但这应该与

$timeStartPoint = mktime(0, 0, 0, 1, ($monthStartPoint ? 1 : 5), 2004);

07-28 00:04