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


Posted in PHP onMarch 19, 2015

本文实例讲述了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 相关文章推荐
IIS+PHP+MySQL+Zend配置 (视频教程)
Dec 13 PHP
php.ini修改php上传文件大小限制的方法详解
Jun 17 PHP
php二维数组转成字符串示例
Feb 17 PHP
PHP调用C#开发的dll类库方法
Jul 28 PHP
PHPExcel内存泄漏问题解决方法
Jan 23 PHP
php常用表单验证类用法实例
Jun 18 PHP
实例讲解如何在PHP的Yii框架中进行错误和异常处理
Mar 17 PHP
轻松实现php文件上传功能
Feb 17 PHP
PHP框架自动加载类文件原理详解
Jun 06 PHP
Laravel如何友好的修改.env配置文件详解
Jun 07 PHP
PHP二维关联数组的遍历方式(实例讲解)
Oct 18 PHP
PHP常见字符串操作函数与用法总结
Mar 04 PHP
php使用gettimeofday函数返回当前时间并存放在关联数组里
Mar 19 #PHP
PHP使用gmdate实现将一个UNIX 时间格式化成GMT文本的方法
Mar 19 #PHP
php查询mysql数据库并将结果保存到数组的方法
Mar 18 #PHP
PHP使用mysql_fetch_object从查询结果中获取对象集的方法
Mar 18 #PHP
PHP使用mysql_fetch_row查询获得数据行列表的方法
Mar 18 #PHP
PHP使用strtotime计算两个给定日期之间天数的方法
Mar 18 #PHP
PHP使用array_fill定义多维数组的方法
Mar 18 #PHP
You might like
php中文本操作的类
2007/03/17 PHP
php中使用PHPExcel读写excel(xls)文件的方法
2014/09/15 PHP
javascript parseInt() 函数的进制转换注意细节
2013/01/08 Javascript
Javascript new Date().valueOf()的作用与时间戳由来详解
2013/04/24 Javascript
浅析Js(Jquery)中,字符串与JSON格式互相转换的示例(直接运行实例)
2013/07/09 Javascript
js中用window.open()打开多个窗口的name问题
2014/03/13 Javascript
javascript批量修改文件编码格式的方法
2015/01/27 Javascript
JavaScript正则表达式中的ignoreCase属性使用详解
2015/06/16 Javascript
详解jQuery中的DOM操作
2016/12/23 Javascript
jQuery中的siblings()是什么意思(推荐)
2016/12/29 Javascript
jquery获取select,option所有的value和text的实例
2017/03/06 Javascript
JavaScript数组排序reverse()和sort()方法详解
2017/12/24 Javascript
关于js的三种使用方式(行内js、内部js、外部js)的程序代码
2018/05/05 Javascript
推荐几个不错的console调试技巧实现
2019/12/20 Javascript
vue使用better-scroll实现滑动以及左右联动
2020/06/30 Javascript
jQuery开发仿QQ版音乐播放器
2020/07/10 jQuery
[46:00]DOTA2上海特级锦标赛主赛事日 - 2 胜者组第一轮#4EG VS Fnatic第一局
2016/03/03 DOTA
Python3使用requests包抓取并保存网页源码的方法
2016/03/15 Python
利用python爬取斗鱼app中照片方法实例
2017/12/03 Python
Python 调用PIL库失败的解决方法
2019/01/08 Python
Python3字符串encode与decode的讲解
2019/04/02 Python
将python运行结果保存至本地文件中的示例讲解
2019/07/11 Python
基于python的selenium两种文件上传操作实现详解
2019/09/19 Python
flask框架json数据的拿取和返回操作示例
2019/11/28 Python
pytorch实现mnist数据集的图像可视化及保存
2020/01/14 Python
Python阶乘求和的代码详解
2020/02/14 Python
使用简单的CSS3属性实现炫酷读者墙效果
2014/01/08 HTML / CSS
前端使用canvas生成盲水印的加密解密的实现
2020/12/16 HTML / CSS
私有程序集与共享程序集有什么区别
2013/04/05 面试题
Ruby如何实现动态方法调用
2012/11/18 面试题
通信研究生自荐信
2014/02/01 职场文书
体育之星事迹材料
2014/05/11 职场文书
农村党支部书记党群众路线四风问题整改措施
2014/09/26 职场文书
离婚起诉书范文2015
2015/05/19 职场文书
2015年小学远程教育工作总结
2015/07/28 职场文书
微信小程序APP页面的之间的相互传递参数以及自定义组件
2022/04/19 Javascript