PHP localtime() 函数

PHP 教程 · 2019-01-24 08:12:16

实例

以一个数值数组和一个关联数组的形式输出本地时间:

<?php
print_r(localtime());
echo "<br><br>";
print_r(localtime(time(),true));
?>

定义和用法

localtime() 函数返回本地时间。

语法

localtime(timestamp,is_assoc);

参数 描述
timestamp 可选。规定 Unix 时间戳。如果未规定 timestamp,则默认为当前的本地时间 time()。
is_assoc 可选。规定返回关联数组还是数值数组。如果为 FALSE,则返回数值数组。如果为 TRUE,则返回关联数组。默认为 FALSE。

关联数组的键名如下所示:

  • [tm_sec] - 秒数
  • [tm_min] - 分钟数
  • [tm_hour] - 小时
  • [tm_mday] - 月份中的第几天
  • [tm_mon] - 年份中的第几个月,从 0 开始表示一月份
  • [tm_year] - 年份,从 1900 开始
  • [tm_wday] - 星期中的第几天 (Sunday=0)
  • [tm_yday] - 年中的第几天
  • [tm_isdst] - 夏令时当前是否生效

技术细节

返回值: 返回包含 Unix 时间戳组件的数组。
PHP 版本: 4+
更新日志: PHP 5.1.0:增加 E_STRICT 和 E_NOTICE 时区错误。

点击查看所有 PHP 教程 文章: https://codercto.com/courses/l/5.html

查看所有标签

An Introduction to the Analysis of Algorithms

An Introduction to the Analysis of Algorithms

Robert Sedgewick、Philippe Flajolet / Addison-Wesley Professional / 1995-12-10 / CAD 67.99

This book is a thorough overview of the primary techniques and models used in the mathematical analysis of algorithms. The first half of the book draws upon classical mathematical material from discre......一起来看看 《An Introduction to the Analysis of Algorithms》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具