
<script>
function CurentTime()
{
var now = new Date();
var year = nowgetFullYear(); //年
var month = nowgetMonth() + 1; //月
var day = nowgetDate(); //日
var hh = nowgetHours(); //时
var mm = nowgetMinutes(); //分
var ss = nowgetSeconds(); //秒
var clock = year + "-";
if(month < 10)
clock += "0";
clock += month + "-";
if(day < 10)
clock += "0";
clock += day + " ";
if(hh < 10)
clock += "0";
clock += hh + ":";
if (mm < 10) clock += '0';
clock += mm + ":";
if (ss < 10) clock += '0';
clock += ss;
return(clock);
}
documentwrite(CurentTime());
</script>
是格林威治时间。
time
返回当前的 Unix 时间戳 (PHP 3, PHP 4, PHP 5)
int time ( )
说明
返回自从 Unix 纪元(格林威治时间 1970 年 1 月 1 日 00:00:00)到当前时间的秒数。
提示:
自 PHP 51 起在 $_SERVER['REQUEST_TIME']
中保存了发起该请求时刻的时间戳。
权威答案,请采纳,有后续问题请加分追问。
PHP的date函数是十分强大的。提供了非常多的格式给我们用。这里主要使用date相关函数就能达成目的,下面直接上代码。
<php$timestr = time();
$now_day = date('w',$timestr);
//获取一周的第一天,注意第一天应该是星期天
$sunday_str = $timestr - $now_day606024;
$sunday = date('Y-m-d', $sunday_str);
//获取一周的最后一天,注意最后一天是星期六
$strday_str = $timestr + (6-$now_day)606024;
$strday = date('Y-m-d', $strday_str);
echo "星期天: $sunday\n";
echo "星期六: $strday\n";
exit;
>
输出结果:
如果你要星期一到星期日的自行加减一天
以上就是关于急!php如何获取当前页面运行的时间全部的内容,包括:急!php如何获取当前页面运行的时间、PHP中time获取时间戳为当前时间,它是格林威治时间还是本地时间、php怎么获取本周的时间格式开始和结束等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)