PHP日期和时间函数。 中的 localtime()

首页 / PHP入门教程 / PHP日期和时间函数。 中的 localtime()

localtime() - 语法

array localtime ( [int $timestamp [, bool $is_associative]] );

localtime()函数返回一个数组,该数组与C函数调用返回的结构的数组相同。

Sr.No Parameter & Description
1

timestamp(可选)

这是一个整数Unix时间戳,如果没有给定时间戳,则默认为当前本地时间。换句话说,它默认为time()的值。

2

is_Associative(可选)

如果设置为false或未提供,则数组将作为常规的数字索引数组返回。如果参数设置为true,那么localtime()是一个关联数组,包含C函数调用localtime返回的结构的所有不同元素。

无涯教程网

关联数组的不同键的名称如下所示:-

链接:https://www.learnfk.comhttps://www.learnfk.com/php/php-function-localtime.html

来源:LearnFk无涯教程网

  • [tm_sec] - seconds
  • [tm_min] - minutes
  • [tm_hour] - hour
  • [tm_mday] - day of the month
  • [tm_mon] - month of the year (January=0)
  • [tm_year] - Years since 1900
  • [tm_wday] - Day of the week (Sunday=0)
  • [tm_yday] - Day of the year
  • [tm_isdst] - Is daylight savings time in effect

localtime() - 示例

<?php
   $localtime=localtime();
   $localtime_assoc=localtime(time(), true);
   
   print_r($localtime);
   print_r($localtime_assoc);
?>

这将产生以下输出-

Array (
   [0] => 24
   [1] => 3
   [2] => 19
   [3] => 3
   [4] => 3
   [5] => 105
   [6] => 0
   [7] => 92
   [8] => 1
)

Array (
   [tm_sec] => 24
   [tm_min] => 3
   [tm_hour] => 19
   [tm_mday] => 3
   [tm_mon] => 3
   [tm_year] => 105
   [tm_wday] => 0
   [tm_yday] => 92
   [tm_isdst] => 1
)

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

赵成的运维体系管理课 -〔赵成〕

Go语言核心36讲 -〔郝林〕

玩转webpack -〔程柳锋〕

分布式技术原理与算法解析 -〔聂鹏程〕

设计模式之美 -〔王争〕

跟月影学可视化 -〔月影〕

Selenium自动化测试实战 -〔郭宏志〕

深入剖析Java新特性 -〔范学雷〕

手把手教你落地DDD -〔钟敬〕

好记忆不如烂笔头。留下您的足迹吧 :)