男女疯狂一边摸一边做羞羞视频|啊好深好硬快点用力别停动态图|亚洲一区无码中文字幕|特级无码毛片免费视频播放▽|久久狠狠躁免费观看|国内精品久久久久久网站

mktime

(PHP 4, PHP 5, PHP 7, PHP 8)

mktime取得一個(gè)日期的 Unix 時(shí)間戳

說(shuō)明

mktime(
    int $hour = date("H"),
    int $minute = date("i"),
    int $second = date("s"),
    int $month = date("n"),
    int $day = date("j"),
    int $year = date("Y"),
    int $is_dst = -1
): int

根據給出的參數返回 Unix 時(shí)間戳。時(shí)間戳是一個(gè)長(cháng)整數,包含了從 Unix 紀元(January 1 1970 00:00:00 GMT)到給定時(shí)間的秒數。

參數可以從右向左省略,任何省略的參數會(huì )被設置成本地日期和時(shí)間的當前值。

注釋

注意:

As of PHP 5.1, when called with no arguments, mktime() throws an E_STRICT notice: use the time() function instead.

參數

hour

小時(shí)數。 The number of the hour relative to the start of the day determined by month, day and year. Negative values reference the hour before midnight of the day in question. Values greater than 23 reference the appropriate hour in the following day(s).

minute

分鐘數。 The number of the minute relative to the start of the hour. Negative values reference the minute in the previous hour. Values greater than 59 reference the appropriate minute in the following hour(s).

second

秒數(一分鐘之內)。 The number of seconds relative to the start of the minute. Negative values reference the second in the previous minute. Values greater than 59 reference the appropriate second in the following minute(s).

month

月份數。 The number of the month relative to the end of the previous year. Values 1 to 12 reference the normal calendar months of the year in question. Values less than 1 (including negative values) reference the months in the previous year in reverse order, so 0 is December, -1 is November, etc. Values greater than 12 reference the appropriate month in the following year(s).

day

天數。 The number of the day relative to the end of the previous month. Values 1 to 28, 29, 30 or 31 (depending upon the month) reference the normal days in the relevant month. Values less than 1 (including negative values) reference the days in the previous month, so 0 is the last day of the previous month, -1 is the day before that, etc. Values greater than the number of days in the relevant month reference the appropriate day in the following month(s).

year

年份數,可以是兩位或四位數字,0-69 對應于 2000-2069,70-100 對應于 1970-2000。在如今系統中普遍把 time_t 作為一個(gè) 32 位有符號整數的情況下,year 的合法范圍是 1901 到 2038 之間,不過(guò)此限制自 PHP 5.1.0 起已被克服了。

is_dst

本參數可以設為 1,表示正處于夏時(shí)制時(shí)間(DST),0 表示不是夏時(shí)制,或者 -1(默認值)表示不知道是否是夏時(shí)制。如果未知,PHP 會(huì )嘗試自己搞明白。這可能產(chǎn)生不可預知(但并非不正確)的結果。如果 PHP 運行的系統中啟用了 DST 或者 is_dst 設為 1,某些時(shí)間是無(wú)效的。例如 DST 自 2:00 生效,則所有處于 2:00 到 3:00 之間的時(shí)間都無(wú)效,mktime() 會(huì )返回一個(gè)未定義(通常為負)的值。某些系統(例如 Solaris 8)的 DST 在午夜生效,則 DST 生效當天的 0:30 會(huì )被計算為前一天的 23:30。

注意:

自 PHP 5.1.0 起,本參數已被廢棄。應該使用新的時(shí)區處理特性來(lái)替代。

注意:

PHP 7.0.0 起,此參數已經(jīng)被移除。

返回值

mktime() 根據給出的參數返回 Unix 時(shí)間戳。如果參數非法,本函數返回 false(在 PHP 5.1 之前返回 -1)。

錯誤/異常

在每次調用日期/時(shí)間函數時(shí),如果時(shí)區無(wú)效則會(huì )引發(fā) E_NOTICE 錯誤。參見(jiàn) date_default_timezone_set()。

更新日志

版本 說(shuō)明
7.0.0 is_dst參數已經(jīng)被移除。
5.3.0 mktime() now throws E_DEPRECATED notice if the is_dst parameter is used.
5.1.0 is_dst 參數被廢棄。出錯時(shí)函數返回 false 而不再是 -1。修正了本函數可以接受年月日參數全為零。
5.1.0 When called with no arguments, mktime() throws E_STRICT notice. Use the time() function instead.
5.1.0

現在發(fā)布 E_STRICTE_NOTICE 時(shí)區錯誤。

范例

示例 #1 基本例子

<?php
// Set the default timezone to use. Available as of PHP 5.1
date_default_timezone_set('UTC');

// Prints: July 1, 2000 is on a Saturday
echo "July 1, 2000 is on a " date("l"mktime(000712000));

// Prints something like: 2006-04-05T01:02:03+00:00
echo date('c'mktime(123452006));
?>

示例 #2 mktime() 例子

mktime() 在做日期計算和驗證方面很有用,它會(huì )自動(dòng)計算超出范圍的輸入的正確值。例如下面例子中每一行都會(huì )產(chǎn)生字符串 "Jan-01-1998"。

<?php
echo date("M-d-Y"mktime(00012321997));
echo 
date("M-d-Y"mktime(0001311997));
echo 
date("M-d-Y"mktime(000111998));
echo 
date("M-d-Y"mktime(0001198));
?>

示例 #3 下個(gè)月的最后一天

任何給定月份的最后一天都可以被表示為下個(gè)月的第 "0" 天,而不是 -1 天。下面兩個(gè)例子都會(huì )產(chǎn)生字符串 "The last day in Feb 2000 is: 29"。

<?php
$lastday 
mktime(000302000);
echo 
strftime("Last day in Feb 2000 is: %d"$lastday);
$lastday mktime(0004, -312000);
echo 
strftime("Last day in Feb 2000 is: %d"$lastday);
?>

注釋

警告

在 PHP 5.1.0 之前,在任何已知 Windows 版本以及一些其它系統下不支持負的時(shí)間戳。因此年份的有效范圍限制為 1970 到 2038。

參見(jiàn)

  • checkdate() - 驗證一個(gè)格里高里日期
  • gmmktime() - 取得 GMT 日期的 UNIX 時(shí)間戳
  • date() - 格式化一個(gè)本地時(shí)間/日期
  • time() - 返回當前的 Unix 時(shí)間戳

男女疯狂一边摸一边做羞羞视频|啊好深好硬快点用力别停动态图|亚洲一区无码中文字幕|特级无码毛片免费视频播放▽|久久狠狠躁免费观看|国内精品久久久久久网站