Date/Time 函数 业 ,精于勤 荒于嬉.
- Date/Time 函数 date_sun_info Returns an array with information about sunset/sunrise and twilight begin/end
-
发表日期:2021-07-01 08:55:27 | 来源: | 分类:Date/Time 函数
-
示例1
<?php $sun_info = date_sun_info(strtotime("2006-12-12"), 31.7667, 35.2333); foreach ($sun_info as $key => $val) { echo "$key: " . date("H:i:s", $val) . "\n"; } ?>示例2
<?php var_dump(date_sun_info(strtotime("2017-12-21"), 90, 0)); ?>示例3
<?php var_dump(date_sun_info(strtotime("2017-06-21"), 90, 0)); ?>
- Date/Time 函数 date_sunrise 返回给定的日期与地点的日出时间
-
发表日期:2021-07-01 08:55:27 | 来源: | 分类:Date/Time 函数
-
示例1
<?php /* 计算葡萄牙里斯本的日出时间Latitude: 北纬 38.4 度Longitude: 西经 9 度Zenith ~= 90offset: +1 GMT*/ echo date("D M d Y"). ', sunrise time : ' .date_sunrise(time(), SUNFUNCS_RET_STRING, 38.4, -9, 90, 1); ?>
- Date/Time 函数 date_sunset 返回给定的日期与地点的日落时间
-
发表日期:2021-07-01 08:55:27 | 来源: | 分类:Date/Time 函数
-
示例1
<?php /* calculate the sunset time for Lisbon, PortugalLatitude: 38.4 NorthLongitude: 9 WestZenith ~= 90offset: +1 GMT*/ echo date("D M d Y"). ', sunset time : ' .date_sunset(time(), SUNFUNCS_RET_STRING, 38.4, -9, 90, 1); ?>
- Date/Time 函数 date_time_set 别名 DateTime::setTime()
-
发表日期:2021-07-01 08:55:27 | 来源: | 分类:Date/Time 函数
-
date_time_set
(PHP 5 >= 5.2.0, PHP 7, PHP 8)
date_time_set — 别名 DateTime::setTime()
说明
此函数是该函数的别名: DateTime::setTime()
- Date/Time 函数 date_timestamp_get 别名 DateTime::getTimestamp()
-
发表日期:2021-07-01 08:55:27 | 来源: | 分类:Date/Time 函数
-
date_timestamp_get
(PHP 5 >= 5.3.0, PHP 7, PHP 8)
date_timestamp_get — 别名 DateTime::getTimestamp()
说明
此函数是该函数的别名: DateTime::getTimestamp()
- Date/Time 函数 date_timestamp_set 别名 DateTime::setTimestamp()
-
发表日期:2021-07-01 08:55:27 | 来源: | 分类:Date/Time 函数
-
date_timestamp_set
(PHP 5 >= 5.3.0, PHP 7, PHP 8)
date_timestamp_set — 别名 DateTime::setTimestamp()
说明
此函数是该函数的别名: DateTime::setTimestamp()
- Date/Time 函数 date_timezone_get 别名 DateTime::getTimezone()
-
发表日期:2021-07-01 08:55:27 | 来源: | 分类:Date/Time 函数
-
date_timezone_get
(PHP 5 >= 5.2.0, PHP 7, PHP 8)
date_timezone_get — 别名 DateTime::getTimezone()
说明
此函数是该函数的别名: DateTime::getTimezone()
- Date/Time 函数 date_timezone_set 别名 DateTime::setTimezone()
-
发表日期:2021-07-01 08:55:27 | 来源: | 分类:Date/Time 函数
-
date_timezone_set
(PHP 5 >= 5.2.0, PHP 7, PHP 8)
date_timezone_set — 别名 DateTime::setTimezone()
说明
此函数是该函数的别名: DateTime::setTimezone()
- Date/Time 函数 date 格式化一个本地时间/日期
-
发表日期:2021-07-01 08:55:27 | 来源: | 分类:Date/Time 函数
-
示例1
<?php // 设定要用的默认时区。自 PHP 5.1 可用date_default_timezone_set('UTC'); // 输出类似:Mondayecho date("l"); // 输出类似:Monday 15th of August 2005 03:12:46 PMecho date('l dS \of F Y h:i:s A'); // 输出:July 1, 2000 is on a Saturdayecho "July 1, 2000 is on a " . date("l", mktime(0, 0, 0, 7, 1, 2000)); /* 在格式参数中使用常量 */ // 输出类似:Wed, 25 Sep 2013 15:28:57 -0700echo date(DATE_RFC2822); // 输出类似:2000-07-01T00:00:00+00:00echo date(DATE_ATOM, mktime(0, 0, 0, 7, 1, 2000)); ?>示例2
<?php // prints something like: Wednesday the 15thecho date("l \\t\h\e jS"); ?>示例3
<?php $tomorrow = mktime(0, 0, 0, date("m") , date("d")+1, date("Y")); $lastmonth = mktime(0, 0, 0, date("m")-1, date("d"), date("Y")); $nextyear = mktime(0, 0, 0, date("m"), date("d"), date("Y")+1); ?>示例4
<?php // 假定今天是:March 10th, 2001, 5:16:18 pm$today = date("F j, Y, g:i a"); // March 10, 2001, 5:16 pm$today = date("m.d.y"); // 03.10.01$today = date("j, n, Y"); // 10, 3, 2001$today = date("Ymd"); // 20010310$today = date('h-i-s, j-m-y, it is w Day z '); // 05-16-17, 10-03-01, 1631 1618 6 Fripm01$today = date('\i\t \i\s \t\h\e jS \d\a\y.'); // It is the 10th day.$today = date("D M j G:i:s T Y"); // Sat Mar 10 15:16:08 MST 2001$today = date('H:m:s \m \i\s\ \m\o\n\t\h'); // 17:03:17 m is month$today = date("H:i:s"); // 17:16:17$today = date("Y-m-d H:i:s"); // 2001-03-10 17:16:18 (MySQL DATETIME 格式)?>示例5
<?php // 设置默认时区。PHP 5.1 之后版本可用date_default_timezone_set('UTC'); // 输出类似: Mondayecho date("l"); // 输出类似:Monday 8th of August 2005 03:12:46 PMecho date('l jS \of F Y h:i:s A'); // 输出:July 1, 2000 is on a Saturdayecho "July 1, 2000 is on a " . date("l", mktime(0, 0, 0, 7, 1, 2000)); /* 使用格式常量 */ // 输出类似: Mon, 15 Aug 2005 15:12:46 UTCecho date(DATE_RFC822); // 输出类似:2000-07-01T00:00:00+00:00echo date(DATE_ATOM, mktime(0, 0, 0, 7, 1, 2000)); ?>示例6
<?php // 输出类似: Wednesday the 15thecho date('l \t\h\e jS'); ?>示例7
<?php $tomorrow = mktime(0, 0, 0, date("m") , date("d")+1, date("Y")); $lastmonth = mktime(0, 0, 0, date("m")-1, date("d"), date("Y")); $nextyear = mktime(0, 0, 0, date("m"), date("d"), date("Y")+1); ?>示例8
<?php // 假设今天是 2001 年 3 月 10 日下午 5 点 16 分 18 秒,// 并且位于山区标准时间(MST)时区$today = date("F j, Y, g:i a"); // March 10, 2001, 5:16 pm$today = date("m.d.y"); // 03.10.01$today = date("j, n, Y"); // 10, 3, 2001$today = date("Ymd"); // 20010310$today = date('h-i-s, j-m-y, it is w Day'); // 05-16-18, 10-03-01, 1631 1618 6 Satpm01$today = date('\i\t \i\s \t\h\e jS \d\a\y.'); // it is the 10th day.$today = date("D M j G:i:s T Y"); // Sat Mar 10 17:16:18 MST 2001$today = date('H:m:s \m \i\s\ \m\o\n\t\h'); // 17:03:18 m is month$today = date("H:i:s"); // 17:16:18?>
- Date/Time 函数 getdate 取得日期/时间信息
-
发表日期:2021-07-01 08:55:27 | 来源: | 分类:Date/Time 函数
-
示例1
<?php $today = getdate(); print_r($today); ?>
- Date/Time 函数 gettimeofday 取得当前时间
-
发表日期:2021-07-01 08:55:27 | 来源: | 分类:Date/Time 函数
-
示例1
<?php print_r(gettimeofday()); echo gettimeofday(true); ?>
- Date/Time 函数 gmdate 格式化一个 GMT/UTC 日期/时间
-
发表日期:2021-07-01 08:55:27 | 来源: | 分类:Date/Time 函数
-
示例1
<?php echo date("M d Y H:i:s", mktime (0,0,0,1,1,2000)); echo gmdate("M d Y H:i:s", mktime (0,0,0,1,1,2000)); ?>
- Date/Time 函数 gmmktime 取得 GMT 日期的 UNIX 时间戳
-
发表日期:2021-07-01 08:55:27 | 来源: | 分类:Date/Time 函数
-
示例1
<?php gmmktime(0, 0, 0, 1, 1, 1970); // 在 GMT 和西方合法,在东方不合法?>
- Date/Time 函数 gmstrftime 根据区域设置格式化 GMT/UTC 时间/日期
-
发表日期:2021-07-01 08:55:27 | 来源: | 分类:Date/Time 函数
-
示例1
<?php setlocale(LC_TIME, 'en_US'); echo strftime("%b %d %Y %H:%M:%S", mktime (20,0,0,12,31,98))."\n"; echo gmstrftime("%b %d %Y %H:%M:%S", mktime (20,0,0,12,31,98))."\n"; ?>
- Date/Time 函数 idate 将本地时间日期格式化为整数
-
发表日期:2021-07-01 08:55:27 | 来源: | 分类:Date/Time 函数
-
示例1
<?php $timestamp = strtotime('1st January 2004'); //1072915200// 下面以两位数字格式显示年份,但是因为// 以“0”打头,因此只会显示“4”echo idate('y', $timestamp); ?>
- Date/Time 函数 localtime 取得本地时间
-
发表日期:2021-07-01 08:55:28 | 来源: | 分类:Date/Time 函数
-
示例1
<?php $localtime = localtime(); $localtime_assoc = localtime(time(), true); print_r($localtime); print_r($localtime_assoc); ?>
- Date/Time 函数 microtime 返回当前 Unix 时间戳和微秒数
-
发表日期:2021-07-01 08:55:27 | 来源: | 分类:Date/Time 函数
-
示例1
<?php /** * Simple function to replicate PHP 5 behaviour */ function microtime_float(){ list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec); } $time_start = microtime_float(); // Sleep for a whileusleep(100); $time_end = microtime_float(); $time = $time_end - $time_start; echo "Did nothing in $time seconds\n"; ?>
- Date/Time 函数 mktime 取得一个日期的 Unix 时间戳
-
发表日期:2021-07-01 08:55:28 | 来源: | 分类:Date/Time 函数
-
示例1
<?php // Set the default timezone to use. Available as of PHP 5.1date_default_timezone_set('UTC'); // Prints: July 1, 2000 is on a Saturdayecho "July 1, 2000 is on a " . date("l", mktime(0, 0, 0, 7, 1, 2000)); // Prints something like: 2006-04-05T01:02:03+00:00echo date('c', mktime(1, 2, 3, 4, 5, 2006)); ?>示例2
<?php echo date("M-d-Y", mktime(0, 0, 0, 12, 32, 1997)); echo date("M-d-Y", mktime(0, 0, 0, 13, 1, 1997)); echo date("M-d-Y", mktime(0, 0, 0, 1, 1, 1998)); echo date("M-d-Y", mktime(0, 0, 0, 1, 1, 98)); ?>示例3
<?php $lastday = mktime(0, 0, 0, 3, 0, 2000); echo strftime("Last day in Feb 2000 is: %d", $lastday); $lastday = mktime(0, 0, 0, 4, -31, 2000); echo strftime("Last day in Feb 2000 is: %d", $lastday); ?>
- Date/Time 函数 strftime 根据区域设置格式化本地时间/日期
-
发表日期:2021-07-01 08:55:28 | 来源: | 分类:Date/Time 函数
-
示例1
<?php setlocale(LC_TIME, "C"); echo strftime("%A"); setlocale(LC_TIME, "fi_FI"); echo strftime(" in Finnish is %A,"); setlocale(LC_TIME, "fr_FR"); echo strftime(" in French %A and"); setlocale(LC_TIME, "de_DE"); echo strftime(" in German %A.\n"); ?>示例2
<?php /* December 2002 / January 2003ISOWk M Tu W Thu F Sa Su----- ----------------------------51 16 17 18 19 20 21 2252 23 24 25 26 27 28 291 30 31 1 2 3 4 52 6 7 8 9 10 11 123 13 14 15 16 17 18 19 */ // 输出: 12/28/2002 - %V,%G,%Y = 52,2002,2002echo "12/28/2002 - %V,%G,%Y = " . strftime("%V,%G,%Y", strtotime("12/28/2002")) . "\n"; // 输出: 12/30/2002 - %V,%G,%Y = 1,2003,2002echo "12/30/2002 - %V,%G,%Y = " . strftime("%V,%G,%Y", strtotime("12/30/2002")) . "\n"; // 输出: 1/3/2003 - %V,%G,%Y = 1,2003,2003echo "1/3/2003 - %V,%G,%Y = " . strftime("%V,%G,%Y",strtotime("1/3/2003")) . "\n"; // 输出: 1/10/2003 - %V,%G,%Y = 2,2003,2003echo "1/10/2003 - %V,%G,%Y = " . strftime("%V,%G,%Y",strtotime("1/10/2003")) . "\n"; /* December 2004 / January 2005ISOWk M Tu W Thu F Sa Su----- ----------------------------51 13 14 15 16 17 18 1952 20 21 22 23 24 25 2653 27 28 29 30 31 1 21 3 4 5 6 7 8 92 10 11 12 13 14 15 16 */ // 输出: 12/23/2004 - %V,%G,%Y = 52,2004,2004echo "12/23/2004 - %V,%G,%Y = " . strftime("%V,%G,%Y",strtotime("12/23/2004")) . "\n"; // 输出: 12/31/2004 - %V,%G,%Y = 53,2004,2004echo "12/31/2004 - %V,%G,%Y = " . strftime("%V,%G,%Y",strtotime("12/31/2004")) . "\n"; // 输出: 1/2/2005 - %V,%G,%Y = 53,2004,2005echo "1/2/2005 - %V,%G,%Y = " . strftime("%V,%G,%Y",strtotime("1/2/2005")) . "\n"; // 输出: 1/3/2005 - %V,%G,%Y = 1,2005,2005echo "1/3/2005 - %V,%G,%Y = " . strftime("%V,%G,%Y",strtotime("1/3/2005")) . "\n"; ?>示例3
<?php // Jan 1: results in: '%e%1%' (%%, e, %%, %e, %%)$format = '%%e%%%e%%'; // Check for Windows to find and replace the %e // modifier correctlyif (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { $format = preg_replace('#(?<!%)((?:%%)*)%e#', '</refsect1>%#d', $format); } echo strftime($format); ?>示例4
<?php // Describe the formats.$strftimeFormats = array( 'A' => 'A full textual representation of the day', 'B' => 'Full month name, based on the locale', 'C' => 'Two digit representation of the century (year divided by 100, truncated to an integer)', 'D' => 'Same as "%m/%d/%y"', 'E' => '', 'F' => 'Same as "%Y-%m-%d"', 'G' => 'The full four-digit version of %g', 'H' => 'Two digit representation of the hour in 24-hour format', 'I' => 'Two digit representation of the hour in 12-hour format', 'J' => '', 'K' => '', 'L' => '', 'M' => 'Two digit representation of the minute', 'N' => '', 'O' => '', 'P' => 'lower-case "am" or "pm" based on the given time', 'Q' => '', 'R' => 'Same as "%H:%M"', 'S' => 'Two digit representation of the second', 'T' => 'Same as "%H:%M:%S"', 'U' => 'Week number of the given year, starting with the first Sunday as the first week', 'V' => 'ISO-8601:1988 week number of the given year, starting with the first week of the year with at least 4 weekdays, with Monday being the start of the week', 'W' => 'A numeric representation of the week of the year, starting with the first Monday as the first week', 'X' => 'Preferred time representation based on locale, without the date', 'Y' => 'Four digit representation for the year', 'Z' => 'The time zone offset/abbreviation option NOT given by %z (depends on operating system)', 'a' => 'An abbreviated textual representation of the day', 'b' => 'Abbreviated month name, based on the locale', 'c' => 'Preferred date and time stamp based on local', 'd' => 'Two-digit day of the month (with leading zeros)', 'e' => 'Day of the month, with a space preceding single digits', 'f' => '', 'g' => 'Two digit representation of the year going by ISO-8601:1988 standards (see %V)', 'h' => 'Abbreviated month name, based on the locale (an alias of %b)', 'i' => '', 'j' => 'Day of the year, 3 digits with leading zeros', 'k' => '', 'l' => 'Hour in 12-hour format, with a space preceeding single digits', 'm' => 'Two digit representation of the month', 'n' => 'A newline character ("\n")', 'o' => '', 'p' => 'UPPER-CASE "AM" or "PM" based on the given time', 'q' => '', 'r' => 'Same as "%I:%M:%S %p"', 's' => 'Unix Epoch Time timestamp', 't' => 'A Tab character ("\t")', 'u' => 'ISO-8601 numeric representation of the day of the week', 'v' => '', 'w' => 'Numeric representation of the day of the week', 'x' => 'Preferred date representation based on locale, without the time', 'y' => 'Two digit representation of the year', 'z' => 'Either the time zone offset from UTC or the abbreviation (depends on operating system)', '%' => 'A literal percentage character ("%")',); // Results.$strftimeValues = array(); // Evaluate the formats whilst suppressing any errors.foreach($strftimeFormats as $format => $description){ if (False !== ($value = @strftime("%{ $format} "))){ $strftimeValues[$format] = $value; } } // Find the longest value.$maxValueLength = 2 + max(array_map('strlen', $strftimeValues)); // Report known formats.foreach($strftimeValues as $format => $value){ echo "Known format : '{ $format} ' = ", str_pad("'{ $value} '", $maxValueLength), " ( { $strftimeFormats[$format]} )\n"; } // Report unknown formats.foreach(array_diff_key($strftimeFormats, $strftimeValues) as $format => $description){ echo "Unknown format : '{ $format} ' ", str_pad(' ', $maxValueLength), ($description ? " ( { $description} )" : ''), "\n"; } ?>
- Date/Time 函数 strptime 解析由 strftime() 生成的日期/时间
-
发表日期:2021-07-01 08:55:28 | 来源: | 分类:Date/Time 函数
-
示例1
<?php $format = '%d/%m/%Y %H:%M:%S'; $strf = strftime($format); echo "$strf\n"; print_r(strptime($strf, $format)); ?>
- PHP杂项(34)
- PHP基础-李炎恢系列课程(20)
- 中文函数手册(0)
- 错误处理 函数(13)
- OPcache 函数(6)
- PHP 选项/信息 函数(54)
- Zip 函数(10)
- Hash 函数(15)
- OpenSSL 函数(63)
- Date/Time 函数(51)
- 目录函数(9)
- Fileinfo 函数(6)
- iconv 函数(11)
- 文件系统函数(81)
- 多字节字符串 函数(57)
- GD 和图像处理 函数(114)
- 可交换图像信息(5)
- Math 函数(50)
- 程序执行函数(11)
- PCNTL 函数(23)
- JSON 函数(4)
- SPL 函数(15)
- URL 函数(10)
- cURL 函数(32)
- 网络 函数(33)
- FTP 函数(36)
- Session 函数(23)
- PCRE 函数(11)
- PCRE 正则语法(19)
- 数组 函数(81)
- 类/对象 函数(18)
- 函数处理 函数(13)
- 变量处理 函数(37)
- SimpleXML 函数(3)
- 杂项 函数(31)
- 字符串 函数(101)
宁公网安备 64010402001209号