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 相关文章推荐
PHP中GET变量的使用
Oct 09 PHP
PHP+javascript模拟Matrix画面
Oct 09 PHP
PHP网站安装程序制作的原理、步骤、注意事项和示例代码
Aug 01 PHP
用mysql_fetch_array()获取当前行数据的方法详解
Jun 05 PHP
深入解析PHP中的(伪)多线程与多进程
Jul 01 PHP
PHP操作文件的一些基本函数使用示例
Nov 18 PHP
php中解析带中文字符的url函数分享
Jan 20 PHP
9个比较实用的php代码片段
Mar 15 PHP
php获取数据库结果集方法(推荐)
Jun 01 PHP
php使用 readfile() 函数设置文件大小大小的方法
Aug 11 PHP
PHP explode()函数用法讲解
Feb 15 PHP
PHP实现统计代码行数小工具
Sep 19 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
php5.2以下版本无json_decode函数的解决方法
2014/05/25 PHP
PHP Primary script unknown 解决方法总结
2019/08/22 PHP
windows系统php环境安装swoole具体步骤
2021/03/04 PHP
js 对象是否存在判断
2009/07/15 Javascript
自制基于jQuery的智能提示插件一枚
2011/02/18 Javascript
基于JQuery的日期联动实现代码
2011/02/24 Javascript
window.location.href的用法(动态输出跳转)
2014/08/09 Javascript
Bootstrap每天必学之下拉菜单
2015/11/25 Javascript
JS实现回到页面顶部动画效果的简单实例
2016/05/24 Javascript
TinyMCE汉化及本地上传图片功能实例详解
2016/05/31 Javascript
浅谈jquery采用attr修改form表单enctype不起作用的问题
2016/11/25 Javascript
JS实现多级菜单中当前菜单不随页面跳转样式而发生变化
2017/05/30 Javascript
详解react如何在组件中获取路由参数
2017/06/15 Javascript
JavaScript反弹动画效果的实现代码
2017/07/13 Javascript
微信小程序实现点击文字页面跳转功能【附源码下载】
2017/12/12 Javascript
基于 D3.js 绘制动态进度条的实例详解
2018/02/26 Javascript
jQuery点击页面其他部分隐藏下拉菜单功能
2018/11/27 jQuery
JS前端知识点总结之内置对象,日期对象和定时器相关操作
2019/07/05 Javascript
python简单获取数组元素个数的方法
2015/07/13 Python
Python找出9个连续的空闲端口
2016/02/01 Python
python logging日志模块的详解
2017/10/29 Python
python:批量统计xml中各类目标的数量案例
2020/03/10 Python
在pycharm中debug 实时查看数据操作(交互式)
2020/06/09 Python
基于Tensorflow的MNIST手写数字识别分类
2020/06/17 Python
PyTorch中clone()、detach()及相关扩展详解
2020/12/09 Python
CSS3实现自定义Checkbox特效实例代码
2017/04/24 HTML / CSS
如何在Canvas上的图形/图像绑定事件监听的实现
2020/09/16 HTML / CSS
日本民宿预约平台:STAY JAPAN
2017/07/01 全球购物
Genny意大利官网:意大利高级时装品牌
2020/04/15 全球购物
中学生在校期间的自我评价分享
2013/11/13 职场文书
医院领导班子四风对照检查材料
2014/09/27 职场文书
2015年班组长工作总结
2015/04/10 职场文书
中秋节感想
2015/08/10 职场文书
Ruby使用Mysql2连接操作MySQL
2022/04/19 Ruby
Apache Hudi 加速传统的批处理模式
2022/04/24 Servers
GoFrame框架数据校验之校验结果Error接口对象
2022/06/21 Golang