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实现求连续子数组最大和问题2种解决方法

本文实例讲述了PHP实现求连续子数组最大和问题2种解决方法。分享给大家供大家参考,具体如下: 问题描述 求子数组的最大和 题目描述: 输入一个整形数组,数组里有正数也有负数。 数组中连续...

php网页标题中文乱码的有效解决方法

刚刚测试了一个php的网页,结果发现标题中文乱码,于是乎,搜搜得到了一个比较不错的答案 在<title>标签前面添加以下一句话就解决了 复制代码 代码如下: <meta...

php的mssql数据库连接类实例

本文实例讲述了php的mssql数据库连接类实例代码,分享给大家供大家参考。 具体实现代码如下: 复制代码 代码如下:class DB_Sql {   var $Host&n...

php中magic_quotes_gpc对unserialize的影响分析

本文实例分析了php中magic_quotes_gpc对unserialize的影响。分享给大家供大家参考。具体如下: magic_quotes_gpc是一个php中一个给单双引号增加一...

php压缩HTML函数轻松实现压缩html/js/Css及注意事项

压缩HTML的起因 如何提高网页加载速度 ,需要怎么对html页面优化相信是每个拟提高建站技术站长曾想到的问题,其实网页优化的方法还是很多。 有童鞋询问higrid如何 压缩HTML,也...