我想知道unix时间戳是什么日子。例如,1322784000
应该告诉我此时间戳是First Friday
,其中1326989000
将返回Third Thursday
。我不知道从哪里开始,以前有人做过这样的事情,可以帮我一把。
答案 0 :(得分:1)
您可以使用此代码来确定:
$ts=array(1322784000, 1326989000, 1323216000, strtotime('2011-12-28'), strtotime('2011-12-21'), strtotime('2011-12-28'), strtotime('2011-12-29') );
foreach ($ts as $t) {
$dt = new DateTime('@' . $t);
$d = ceil($dt->format('d')/7);
$str="";
switch ($d) {
case 1: $str = "1st ";
break;
case 2: $str = "2nd ";
break;
case 3: $str = "3rd ";
break;
case 4: $str = "4th ";
break;
default: $str = "5th ";
break;
}
echo $dt->format('Y-m-d H:i:s') . " is: " . $str . $dt->format('l') . "\n";
}
<强>输出强>
2011-12-02 00:00:00 is: 1st Friday
2012-01-19 16:03:20 is: 3rd Thursday
2011-12-07 00:00:00 is: 1st Wednesday
2011-12-28 00:00:00 is: 4th Wednesday
2011-12-21 00:00:00 is: 3rd Wednesday
2011-12-28 00:00:00 is: 4th Wednesday
2011-12-29 00:00:00 is: 5th Thursday
答案 1 :(得分:-1)