最近2018中文字幕在日韩欧美国产成人片_国产日韩精品一区二区在线_在线观看成年美女黄网色视频_国产精品一区三区五区_国产精彩刺激乱对白_看黄色黄大色黄片免费_人人超碰自拍cao_国产高清av在线_亚洲精品电影av_日韩美女尤物视频网站

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
php根據(jù)年月日查詢數(shù)據(jù) php獲取月份天數(shù)

php根據(jù)年月獲取當月天數(shù)及日期數(shù)組的方法

本文實例講述了php根據(jù)年月獲取當月天數(shù)及日期數(shù)組的方法。分享給大家供大家參考,具體如下:

在興和等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務理念,為客戶提供網(wǎng)站設(shè)計制作、網(wǎng)站設(shè)計 網(wǎng)站設(shè)計制作按需開發(fā),公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),品牌網(wǎng)站設(shè)計,成都營銷網(wǎng)站建設(shè),外貿(mào)營銷網(wǎng)站建設(shè),興和網(wǎng)站建設(shè)費用合理。

function

get_day(

$date

)

{

$tem

=

explode('-'

,

$date);

//切割日期

得到年份和月份

$year

=

$tem['0'];

$month

=

$tem['1'];

if(

in_array($month

,

array(

1

,

3

,

5

,

7

,

8

,

01

,

03

,

05

,

07

,

08

,

10

,

12)))

{

//

$text

=

$year.'年的'.$month.'月有31天';

$text

=

'31';

}

elseif(

$month

==

2

)

{

if

(

$year%400

==

||

($year%4

==

$year%100

!==

0)

)

//判斷是否是閏年

{

//

$text

=

$year.'年的'.$month.'月有29天';

$text

=

'29';

}

else{

//

$text

=

$year.'年的'.$month.'月有28天';

$text

=

'28';

}

}

else{

//

$text

=

$year.'年的'.$month.'月有30天';

$text

=

'30';

}

return

$text;

}

echo

get_day('2016-8-1');

運行結(jié)果為:31

改造,返回日期數(shù)組:

/**

*

獲取當月天數(shù)

*

@param

$date

*

@param

$rtype

1天數(shù)

2具體日期數(shù)組

*

@return

*/

function

get_day(

$date

,$rtype

=

'1')

{

$tem

=

explode('-'

,

$date);

//切割日期

得到年份和月份

$year

=

$tem['0'];

$month

=

$tem['1'];

if(

in_array($month

,

array(

1

,

3

,

5

,

7

,

8

,

01

,

03

,

05

,

07

,

08

,

10

,

12)))

{

//

$text

=

$year.'年的'.$month.'月有31天';

$text

=

'31';

}

elseif(

$month

==

2

)

{

if

(

$year%400

==

||

($year%4

==

$year%100

!==

0)

)

//判斷是否是閏年

{

//

$text

=

$year.'年的'.$month.'月有29天';

$text

=

'29';

}

else{

//

$text

=

$year.'年的'.$month.'月有28天';

$text

=

'28';

}

}

else{

//

$text

=

$year.'年的'.$month.'月有30天';

$text

=

'30';

}

if

($rtype

==

'2')

{

for

($i

=

1;

$i

=

$text

;

$i

++

)

{

$r[]

=

$year."-".$month."-".$i;

}

}

else

{

$r

=

$text;

}

return

$r;

}

var_dump(get_day('2016-8-1','2'));

運行結(jié)果如下:

array(31)

{

[0]=

string(8)

"2016-8-1"

[1]=

string(8)

"2016-8-2"

[2]=

string(8)

"2016-8-3"

[3]=

string(8)

"2016-8-4"

[4]=

string(8)

"2016-8-5"

[5]=

string(8)

"2016-8-6"

[6]=

string(8)

"2016-8-7"

[7]=

string(8)

"2016-8-8"

[8]=

string(8)

"2016-8-9"

[9]=

string(9)

"2016-8-10"

[10]=

string(9)

"2016-8-11"

[11]=

string(9)

"2016-8-12"

[12]=

string(9)

"2016-8-13"

[13]=

string(9)

"2016-8-14"

[14]=

string(9)

"2016-8-15"

[15]=

string(9)

"2016-8-16"

[16]=

string(9)

"2016-8-17"

[17]=

string(9)

"2016-8-18"

[18]=

string(9)

"2016-8-19"

[19]=

string(9)

"2016-8-20"

[20]=

string(9)

"2016-8-21"

[21]=

string(9)

"2016-8-22"

[22]=

string(9)

"2016-8-23"

[23]=

string(9)

"2016-8-24"

[24]=

string(9)

"2016-8-25"

[25]=

string(9)

"2016-8-26"

[26]=

string(9)

"2016-8-27"

[27]=

string(9)

"2016-8-28"

[28]=

string(9)

"2016-8-29"

[29]=

string(9)

"2016-8-30"

[30]=

string(9)

"2016-8-31"

}

更多關(guān)于PHP相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《php日期與時間用法總結(jié)》、《PHP數(shù)組(Array)操作技巧大全》、《PHP基本語法入門教程》、《PHP運算與運算符用法總結(jié)》、《php面向?qū)ο蟪绦蛟O(shè)計入門教程》、《PHP網(wǎng)絡編程技巧總結(jié)》、《php字符串(string)用法總結(jié)》、《php+mysql數(shù)據(jù)庫操作入門教程》及《php常見數(shù)據(jù)庫操作技巧匯總》

希望本文所述對大家PHP程序設(shè)計有所幫助。

php按當前年份、季度、當月,查詢mysql數(shù)據(jù)庫并輸出數(shù)組

PHP查詢到的數(shù)據(jù)存放到數(shù)組里面,一般使用$arr[]=$row的方式實現(xiàn),$row是mysql_fetch_array獲得的一行數(shù)據(jù),本身是一個數(shù)組,執(zhí)行上面的語句之后,這一行會添加存放在額為數(shù)組$arr的最后。

典型的例子代碼是這樣的:mysql_connect('127.0.0.1',

'root',

'123456');$sql='select

*

from

test.tab';if

($res=mysql_query($sql)){

while($row=mysql_fetch_array($res))

$result[]=$row;

mysql_free_resule($res);}else

echo

"執(zhí)行SQL語句:$sql\n錯誤:".mysql_error();echo

'查詢結(jié)果在下面的額為數(shù)組里面:';print_r($result);echo

'';

thinkphp中如何通過日期查詢數(shù)據(jù)庫

方法:

$time=strtotime($_POST['dates']);//dates為從文本框獲得的日期

$sql='select * from think_mytask where strtotime(starttime)=$time and strtotime(endtime)=$time';

$admin1=new Model('mytask');

$list=$admin1-query($sql);

php 按年月日時間查詢數(shù)據(jù)庫中時間戳字段

后臺接收到 POST 或者 GET 過來的這個日期,做個時間戳轉(zhuǎn)化處理,很簡單的,用time()函數(shù)

$data = "20150725";

$time = time($data);

var_dump($time);

結(jié)果輸出

int 1437901908


文章名稱:php根據(jù)年月日查詢數(shù)據(jù) php獲取月份天數(shù)
當前路徑:http://fisionsoft.com.cn/article/docschj.html