PHP使用GETDATE获取当前日期时间作为一个关联数组的方法

yipeiwu_com6年前PHP代码库

本文实例讲述了PHP使用GETDATE获取当前日期时间作为一个关联数组的方法。分享给大家供大家参考。具体分析如下:

PHP GETDATE函数是用来获得当前的日期和时间,从操作系统或一个关联数组转换成UNIX风格的日期整数。

语法格式如下

array getdate ();
array getdate (integer $Time);

参数如下:
Arguments

$Time
The number of seconds since midnight before January 1, 1970. (UNIX style.)
Default
The default is the current date and time from the operating system.)

The return value is an associative array containing:

mon The month of the year as a number (1..12)
mday The day of the month (1..31)
year The year (4 digits)
hours The hour of the day (0..23)
minutes The minutes of the hour (0..59)
seconds The seconds of the minute (0..59)
month The month of the year as a word (January..December)
yday The day of the year (0..365)
wday The day of the week as a number (0..6)
weekday The day of the week as a word (Sunday..Saturday)
0 Seconds since midnight before January 1, 1970

下面是一个使用范例:

<?php
$Now = getdate();
foreach ($Now as $Key => $Value) {
 echo "$Key => $Value\n";
}
?>

输出结果如下:

seconds => 59
minutes => 14
hours => 7
mday => 26
wday => 6
mon => 12
year => 2009
yday => 359
weekday => Saturday
month => December
0 => 1261811699

希望本文所述对大家的php程序设计有所帮助。

相关文章

php正则匹配html中带class的div并选取其中内容的方法

本文实例讲述了php正则匹配html中带class的div并选取其中内容的方法。分享给大家供大家参考。具体分析如下: 先看一段html代码: 复制代码 代码如下:<div clas...

php 获取SWF动画截图示例代码

1.下载附件,并安装,方法看附件中的帮助 2.拷贝代码进合适位置,生成图片,怎么处理,自己看着办喽 复制代码 代码如下: $oldswf = "/uploads/swf/test.swf...

php查询ip所在地的方法

本文实例讲述了php查询ip所在地的方法。分享给大家供大家参考。 具体实现方法如下: 复制代码 代码如下:<?php /** *@ date  &n...

php 使用redis锁限制并发访问类示例

本文介绍了php 使用redis锁限制并发访问类,并详细的介绍了并发访问限制方法。 1.并发访问限制问题 对于一些需要限制同一个用户并发访问的场景,如果用户并发请求多次,而服务器处理...

实例讲解PHP面向对象之多态

什么是多态性? 多态性是继数据库抽象和继承后,面向对象语言的第三个特征。多态即多种形态,具有表现多种形态的能力特征。在面向对象中表示根据对象的类型以不同方式处理。多态性允许每个对象以适合...