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成功操作redis cluster集群的实例教程

php成功操作redis cluster集群的实例教程

前言 java操作redis cluster集群可使用jredis php要操作redis cluster集群有两种方式: 1、使用phpredis扩展,这是个c扩展,性能更高,但是ph...

php通过array_merge()函数合并两个数组的方法

本文实例讲述了php通过array_merge()函数合并两个数组的方法。分享给大家供大家参考。具体分析如下: php通过array_merge()函数合并两个数组,array_merg...

php修改时间格式的代码

修改时间格式: date("Y-m-d",strtotime($list['pubdate'])); 学习解释:将时间放入strtotime为时间戳后用date()转化格式.下面写了两个...

PHP安全性漫谈

PHP安全性漫谈

一、apache server安全性设置 1、以Nobody用户运行 一般情况下,Apache是由Root 来安装和运行的。如果Apache Server进程具有Root用户特权,那么它...

两种设置php载入页面时编码的方法

php载入页面时设置页面编码的两种方法 1:输出meta标签: 1、在php mvc的控制器里面或php页面echo '<meta http-equiv="content-type...