无涯教程-PHP日期和时间函数。 - getdate()

45 阅读1分钟

getdate() - 语法

array getdate ( [int $timestamp] );

它使用给定的整数时间戳返回根据给定格式字符串格式化的字符串,如果没有给定时间戳,则返回当前时间。换句话说,时间戳是可选的,默认为time()的值。

Sr.No Parameter & Description
1

timestamp(可选)

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

getdate() - 返回值

它返回与typestamp相关的信息的关联数组。返回的数组包含十个元素,这些元素具有格式化日期字符串-时所需的相关信息

  • [seconds] - seconds
  • [minutes] - minutes
  • [hours] - hours
  • [mday] - day of the month
  • [wday] - day of the week
  • [year] - year
  • [yday] - day of the year
  • [weekday] - name of the weekday
  • [month] - name of the month

getdate() - 示例

<?php
   $today=getdate();
   print_r($today);
?>

这将产生以下输出-

Array (
   [seconds] => 40
   [minutes] => 58
   [hours]   => 21
   [mday]    => 17
   [wday]    => 2
   [mon]     => 6
   [year]    => 2003
   [yday]    => 167
   [weekday] => Tuesday
   [month]   => June
   [0]       => 1055901520
)

参考链接

www.learnfk.com/php/php-fun…