欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程语言 > php >内容正文

php

getdate函数_PHP getdate()函数与示例

发布时间:2023/12/1 php 56 豆豆
生活随笔 收集整理的这篇文章主要介绍了 getdate函数_PHP getdate()函数与示例 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

getdate函数

PHP getdate()函数 (PHP getdate() function)

getdate() function is used to get the local date/time (or it is also used to get the date/time based on the given timestamp.

getdate()函数用于获取本地日期/时间(或也用于根据给定的时间戳获取日期/时间。

Syntax:

句法:

getdate(timestamp);

Parameter(s):

参数:

  • timestamp – It is an optional parameter which specifies the timestamp (which is based on an integer UNIX timestamp) – if we do not pass the timestamp the function returns the local date/time.

    timestamp –这是一个可选参数,用于指定时间戳(基于整数UNIX时间戳)–如果不传递时间戳,该函数将返回本地日期/时间。

Timestamps: Following are the timestamps,

时间戳记 :以下是时间戳记,

  • seconds - it is used to get the time in seconds

    秒 -用于获取时间(以秒为单位)

  • minutes - it is used to get the time in minutes

    分钟 -用于获取以分钟为单位的时间

  • hours - it is used to get the time in hours

    小时 -用于获取小时数

  • mday - it is used to get the day of the month

    mday-用于获取每月的某天

  • wday - it is used to get the day of the week

    wday-用于获取星期几

  • mon - it is used to get the month

    mon-用于获取月份

  • year - it is used to get the year

    年 -用于获取年份

  • yday - it is used to get the day of the year

    yday-用于获取一年中的某天

  • weekday - it is used to get the name of the week

    工作日 -用于获取星期名称

  • month - it is used to get the name of the month

    month-用于获取月份的名称

  • 0 - it is used to get the seconds since Unix Epoch

    0-用于获取自Unix Epoch以来的秒数

Return value:

返回值:

It returns an array of the date/time information with the timestamp

它返回带有时间戳的日期/时间信息数组

Example: PHP code to demonstrate the example of getdate() function

示例:PHP代码演示getdate()函数的示例

<?php //getting the complete date/time //i.e. local date/time $result = getdate(); echo "getdate() result...\n"; print_r($result);//extracting the indivisual values //based on the timestamps echo "seconds: $result[seconds]\n"; echo "minutes: $result[minutes]\n"; echo "hours: $result[hours]\n"; echo "mday: $result[mday]\n"; echo "wday: $result[wday]\n"; echo "mon: $result[mon]\n"; echo "year: $result[year]\n"; echo "yday: $result[yday]\n"; echo "weekday: $result[weekday]\n"; echo "month: $result[month]\n"; echo "0: $result[0]\n"; ?>

Output

输出量

getdate() result... Array ([seconds] => 28[minutes] => 56[hours] => 12[mday] => 13[wday] => 2[mon] => 8[year] => 2019[yday] => 224[weekday] => Tuesday[month] => August[0] => 1565700988 ) seconds: 28 minutes: 56 hours: 12 mday: 13 wday: 2 mon: 8 year: 2019 yday: 224 weekday: Tuesday month: August 0: 1565700988

Reference: PHP getdate() function

参考: PHP getdate()函数

翻译自: https://www.includehelp.com/php/getdate-function-with-example.aspx

getdate函数

总结

以上是生活随笔为你收集整理的getdate函数_PHP getdate()函数与示例的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。