PHP 獲取本月 本週第一天 最

2021-07-12 07:22:34 字數 1464 閱讀 1493

<?php 

$year = date("y");

$month = date("m");

$allday = date("t");

$strat_time =strtotime($year."-".$month."-1");

$end_time =strtotime($year."-".$month."-".$allday);

echo date("y-m-d",$strat_time );

echo date("y-m-d",$end_time)

?>

獲取本週第一天/最後一天的時間戳

<?php 

$year = date("y");

$month = date("m");

$day = date('w');

$nowmonthday = date("t");

$firstday = date('d') - $day;

if(substr($firstday,0,1) == "-")else

$lastday = date('d') + (7 - $day);

if($lastday >$nowmonthday)else

echo date("y-m-d",$time_1 );

echo date("y-m-d",$time_2)

?>

date_default_timezone_set('prc'); //預設時區

echo "今天:",date("y-m-d",time()),"

";echo "今天:",date("y-m-d",strtotime("18 june 2008")),"

";echo "昨天:",date("y-m-d",strtotime("-1 day")), "

";echo "明天:",date("y-m-d",strtotime("+1 day")), "

";echo "一周後:",date("y-m-d",strtotime("+1 week")), "

";echo "一周零兩天四小時兩秒後:",date("y-m-d g:h:s",strtotime("+1 week 2 days 4 hours 2 seconds")), "

";echo "下個星期四:",date("y-m-d",strtotime("next thursday")), "

";echo "上個周一:".date("y-m-d",strtotime("last monday"))."

";echo "乙個月前:".date("y-m-d",strtotime("last month"))."

";echo "乙個月後:".date("y-m-d",strtotime("+1 month"))."

";echo "十年後:".date("y-m-d",strtotime("+10 year"))."

";

PHP獲取本週第一天和最後一天

本週的第一天和最後一天 如下 複製 date new datetime date modify this week first day of week date format y m d date modify this week 6 days end day of week date format...

sql獲得本週,本月,本年第一天最後一天

本週的第一天 select dateadd wk,datediff wk,0,getdate 0 本年的第一天 select dateadd yy,datediff yy,0,getdate 0 本季度的第一天 select dateadd qq,datediff qq,0,getdate 0 當天...

日期獲取本月第一天和最後一天

getfullyear 日期物件獲取年份 yyyy getmonth 獲取月份0 11 getdate 獲取一月中的第幾天 1 31 setdate num 傳數字設定本月日期第幾天 newdate year month,day,hours,可以傳字串或數字 newdate fullyear,mon...