linux下显示时间的时间戳:
当前时间:date +%s
特定时间:date +%s -d "20071126 00:12:00"
PHP中,脚本内容如下:
<?php
echo date('U'); 显示unix的从unix纪元的时间戳
echo strtotime("today")."\n"; 显示当前时间的时间戳
$davytest=strtotime("today")+720; 其中strtotime的类型为int
var_dump(strtotime("today"));
var_dump($davytest);
$stamp = mktime(0, 12, 0, 11, 26, 2007); 将小括号里的时间转换为时间戳,小时,分,秒,月,日,年
echo "mktime".$stamp."\n";
var_dump(getdate($stamp)); 将时间按小时,分,秒,月,日,年,和时间戳,按数组形式显示
echo date("M-d-Y H:i:s", $stamp)."\n"; 将时间戳按月,日,年,小时:分:秒的形式打印出来,注意分是i
?
评论