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程序设计有所帮助。

相关文章

dedecms采集中可以过滤多行代码的正则表达式

过去用dede采集,总是过滤不掉一行以上的代码,只能一行行的过滤,在网上,发现有很多和我一样的菜鸟。随着不断的使用dede采集,对正则有了更进一步的了解,现在偶用一句正则表达式,同样可以...

php取出数组单个值的方法

1.数组arr var_dump(arr) 值如下: array (size=3) 'delete' => array (size=3) 0 => strin...

解析PHP汉字转换拼音的类

网络上类似的代码大多只能在gb2312编码下使用,下面这个类同时能在utf-8编码下将汉字转换为拼音。具体的代码和用法如下:复制代码 代码如下:<?phpfunction Piny...

php 在windows下配置虚拟目录的方法介绍

先打开Apache的conf目录下的httpd.conf文件,在末尾添加如下代码:复制代码 代码如下:<VirtualHost *:80> ServerName w...

PHP+JQuery+Ajax实现分页方法详解

PHP+JQuery+Ajax实现分页方法详解

本文实例讲述了PHP+JQuery+Ajax实现分页的方法。分享给大家供大家参考,具体如下: 为了锻炼下jQuery,决定自己动手写写分页 最终的效果如图: 点击某个字母后,下方显示以该...