
$weekday=array('天','一','二','三','四','五','六');
$showtime=date("Y年n月d日 星期")$weekday[date("w")];
echo $showtime;
你要实现的是不是当前月份和当前月份往前5个月,每个月的第一天是几号号最后一天是几号?如果是的话,我写了一个 能实现你的需求。你的问题让我好纠结。
$currentTime = time();$cyear = floor(date("Y",$currentTime));
$cMonth = floor(date("m",$currentTime));
for($i=0;$i<6;$i++){
$nMonth = $cMonth-$i;
$cyear = $nMonth == 0 ($cyear-1) : $cyear;
$nMonth = $nMonth <= 0 12+$nMonth : $nMonth;
$date = $cyear"-"$nMonth"-1";
$firstday = date('Y-m-01', strtotime($date));
$lastday = date('Y-m-t', strtotime($date));
echo $cyear"年"$nMonth"月";
echo "第一天:"$firstday;
echo "最后一天:"$lastday,"<br>";
}
在文件头加入$stime=microtime(true);
在文件尾加入
$etime=microtime(true);//获取程序执行结束的时间
$total=$etime-$stime; //计算差值
echo "<br />[页面执行时间:{$total} ]秒";
例如
文件头
<php
$stime=microtime(true);
>
文件尾
<php
$etime=microtime(true);//获取程序执行结束的时间
$total=$etime-$stime; //计算差值
echo "<br />[页面执行时间:{$total} ]秒";
这样就可以计算出整个PHP页面执行的时间。纯手打,望采纳。
<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>
以上就是关于php获取当前时间全部的内容,包括:php获取当前时间、php中如何获取最近六个月每个月的起始时间和结束时间、如何用php获取程序执行的时间等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)