php時間戳範圍

2021-08-11 21:01:22 字數 1375 閱讀 1900

這是獲取當月月初和月末的時間戳

$beginthismonth=mktime(0,0,0,date('m'),1,date('y'));

$endthismonth=mktime(23,59,59,date('m'),date('t'),date('y'));

//php獲取今日開始時間戳和結束時間戳

$begintoday=mktime(0,0,0,date('m'),date('d'),date('y'));

$endtoday=mktime(0,0,0,date('m'),date('d')+1,date('y'))-1;

//php獲取昨日起始時間戳和結束時間戳

$beginyesterday=mktime(0,0,0,date('m'),date('d')-1,date('y'));

$endyesterday=mktime(0,0,0,date('m'),date('d'),date('y'))-1;

//php獲取上週起始時間戳和結束時間戳

$beginlastweek=mktime(0,0,0,date('m'),date('d')-date('w')+1-7,date('y'));

$endlastweek=mktime(23,59,59,date('m'),date('d')-date('w')+7-7,date('y'));

//php獲取本月起始時間戳和結束時間戳

$beginthismonth=mktime(0,0,0,date('m'),1,date('y'));

$endthismonth=mktime(23,59,59,date('m'),date('t'),date('y'));

php mktime() 函式用於返回乙個日期的 unix 時間戳。

語法mktime(hour,minute,second,month,day,year,is_dst)

引數  描述

hour

可選。規定小時。

minute

可選。規定分鐘。

second

可選。規定秒。

month

可選。規定用數字表示的月。

day  可選。規定天。

year

可選。規定年。在某些系統上,合法值介於 1901 - 2038 之間。不過在 php 5 中已經不存在這個限制了。

is_dst

可選。如果時間在日光節約時間(dst)期間,則設定為1,否則設定為0,若未知,則設定為-1。

$map['time']  = array('between',array($beginthismonth,$endthismonth));

$mrecharge = $user_recharge->where($map)->sum('recharge_num');

mysql 時間戳有效範圍

事情 from unixtime unix timestamp溢位,無法使用 起因from unixtime返回的結果從1970 01 01到現在為止的秒數,是int型的結果,而int的有效範圍是 2 31 1,2 31 1 即 2147483648,2147483648 2147483648 36...

php 增加時間戳 php如何新增時間戳

php新增時間戳的方法 可以利用mktime 函式來新增。該函式返回乙個日期的unix時間戳,如果錯誤則返回false。具體使用方法如 mktime 0,0,0,date m date d 1,date y mktime 函式返回乙個日期的 unix 時間戳,如果錯誤則返回 false。語法 mkt...

php時間戳累加 php時間戳增加時間的方法

php時間戳增加時間的方法 首先建立乙個php示例檔案 然後通過 strtotime 1 year 方法將當前時間戳增加一年的時間 最後輸出增加後的結果即可。php當前時間戳增加時間 php將當前時間戳增加一年 year echo strtotime 1 year 返回時間戳,如果要轉換成一般時間格...