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

yipeiwu_com5年前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 MemCached高级缓存配置图文教程

PHP MemCached高级缓存配置图文教程

1.Memcache相关介绍 memcache是一个高性能的分布式的内存对象缓存系统,它能够用来存储各种格式的数据,包括图像、视频、文件以及数据库检索的结果等。 使用Memcache的网...

PHP实现的memcache环形队列类实例

本文实例讲述了PHP实现的memcache环形队列类。分享给大家供大家参考。具体如下: 这里介绍了PHP实现的memcache环形队列类。没咋学过数据结构,因为业务需要,所以只是硬着头皮...

php防止站外远程提交表单的方法

本文实例讲述了php防止站外远程提交表单的方法,分享给大家供大家参考。具体实现方法如下: 一般来说防止站长提交表单无非就是对每一次打开表单或提交数据都会需要加一个token来进行验证了,...

PHP中数组的三种排序方法分享

一、冒泡排序法 说明:找到最大的数,排列到最后面,然后继续找 例: 复制代码 代码如下: $arr = array(3,5,-1,0,2); for($i=0;$i<count($...

PHP多进程编程之僵尸进程问题的理解

PHP多进程编程之僵尸进程问题的理解 使用pcntl_fork函数可以让PHP实现多进程并发或者异步处理的效果:https://www.jb51.net/article/125789.h...