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 相关文章推荐
BBS(php &amp; mysql)完整版(七)
Oct 09 PHP
PHP与javascript的两种交互方式
Oct 09 PHP
使用TinyButStrong模板引擎来做WEB开发
Mar 16 PHP
PHP学习之数组的定义和填充
Apr 17 PHP
php cli 小技巧
Jun 03 PHP
php记录代码执行时间(实现代码)
Jul 05 PHP
Yii操作数据库的3种方法
Mar 11 PHP
PHP中使用smarty生成静态文件的例子
Apr 24 PHP
PHP遍历数组的方法汇总
Apr 30 PHP
jQuery+PHP发布的内容进行无刷新分页(Fckeditor)
Oct 22 PHP
thinkPHP框架实现的简单计算器示例
Dec 07 PHP
vmware linux系统安装最新的php7图解
Apr 14 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 静态页面中显示动态内容
2009/08/14 PHP
用php解析html的实现代码
2011/08/08 PHP
PHP模板引擎Smarty的缓存使用总结
2014/04/24 PHP
php安全配置记录和常见错误梳理(总结)
2017/03/28 PHP
yii2多图上传组件的使用教程
2018/05/10 PHP
Javascript 遍历对象中的子对象
2009/07/03 Javascript
JavaScript 异步调用框架 (Part 2 - 用例设计)
2009/08/03 Javascript
javascript 密码强度验证规则、打分、验证(给出前端代码,后端代码可根据强度规则翻译)
2010/05/18 Javascript
让图片旋转任意角度及JQuery插件使用介绍
2013/03/20 Javascript
关于jQuery参考实例2.0 用jQuery选择元素
2013/04/07 Javascript
JavaScript 数组详解
2013/10/10 Javascript
鼠标经过tr时,改变tr当前背景颜色
2014/01/13 Javascript
js获取当前页面的url网址信息
2014/06/12 Javascript
浅谈Javascript数组的使用
2015/07/29 Javascript
js实现input框文字动态变换显示效果
2015/08/19 Javascript
AngularJS ng-controller 指令简单实例
2016/08/01 Javascript
微信小程序微信支付接入开发实例详解
2017/04/12 Javascript
AngularJS实现表单元素值绑定操作示例
2017/10/11 Javascript
基于redis的小程序登录实现方法流程分析
2020/05/25 Javascript
vant 时间选择器--开始时间和结束时间实例
2020/11/04 Javascript
vue+iview实现文件上传
2020/11/17 Vue.js
Python3中多线程编程的队列运作示例
2015/04/16 Python
python黑魔法之参数传递
2016/02/12 Python
python开发之list操作实例分析
2016/02/22 Python
python中模块查找的原理与方法详解
2017/08/11 Python
python通过TimedRotatingFileHandler按时间切割日志
2019/07/17 Python
Python3 chardet模块查看编码格式的例子
2019/08/14 Python
pytorch 实现在预训练模型的 input上增减通道
2020/01/06 Python
Python制作运行进度条的实现效果(代码运行不无聊)
2021/02/24 Python
阿玛尼美妆加拿大官方商城:Giorgio Armani Beauty加拿大
2017/10/24 全球购物
介绍下Java的输入输出流
2014/01/22 面试题
先进员工获奖感言
2014/08/14 职场文书
党课心得体会范文
2014/09/09 职场文书
2015年超市收银员工作总结
2015/04/25 职场文书
如何用PHP websocket实现网页实时聊天
2021/05/26 PHP
AJAX实现省市县三级联动效果
2021/10/16 Javascript