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 相关文章推荐
给多个地址发邮件的类
Oct 09 PHP
第五章 php数组操作
Dec 30 PHP
php堆排序(heapsort)练习
Nov 13 PHP
PHP的fsockopen、pfsockopen函数被主机商禁用的解决办法
Jul 08 PHP
对PHP新手的一些建议(PHP学习经验总结)
Aug 20 PHP
php+xml编程之xpath的应用实例
Jan 24 PHP
Smarty分页实现方法完整实例
May 11 PHP
php实现的debug log日志操作类实例
Jul 12 PHP
Yii CFileCache 获取不到值的原因分析
Feb 08 PHP
PHP+AJAX 投票器功能
Nov 11 PHP
PHP下用Swoole实现Actor并发模型的方法
Jun 12 PHP
php优化查询foreach代码实例讲解
Mar 24 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生成4位数字验证码的实现代码
2015/11/23 PHP
PHP的全局错误处理详解
2016/04/25 PHP
PHP从数组中删除元素的四种方法实例
2017/05/12 PHP
使用Jquery搭建最佳用户体验的登录页面之记住密码自动登录功能(含后台代码)
2011/07/10 Javascript
基于jquery的文本框与autocomplete结合使用(asp.net+json)
2012/05/30 Javascript
jquery实现每个数字上都带进度条的幻灯片
2013/02/20 Javascript
JS 如何获取radio选中后的值及不选择取radio的值
2013/10/28 Javascript
jquery实现动态菜单的实例代码
2013/11/28 Javascript
js通过iframe加载外部网页的实现代码
2015/04/05 Javascript
基于javascript制作微信聊天面板
2020/08/09 Javascript
详解nodejs微信公众号开发——1.接入微信公众号
2017/04/10 NodeJs
ionic+AngularJs实现获取验证码倒计时按钮
2017/04/22 Javascript
nodeJS服务器的创建和重新启动的实现方法
2018/05/12 NodeJs
微信小程序自定义弹窗wcPop插件
2018/11/19 Javascript
ES6入门教程之Array.from()方法
2019/03/23 Javascript
微信小程序跨页面数据传递事件响应实现过程解析
2019/12/19 Javascript
vue+flask实现视频合成功能(拖拽上传)
2021/03/04 Vue.js
python多线程http下载实现示例
2013/12/30 Python
python基础知识小结之集合
2015/11/25 Python
ubuntu 16.04下python版本切换的方法
2019/06/14 Python
Spring Cloud Feign高级应用实例详解
2019/12/10 Python
Python +Selenium解决图片验证码登录或注册问题(推荐)
2020/02/09 Python
Python3创建Django项目的几种方法(3种)
2020/06/03 Python
Python3实现建造者模式的示例代码
2020/06/28 Python
keras的backend 设置 tensorflow,theano操作
2020/06/30 Python
Python常用base64 md5 aes des crc32加密解密方法汇总
2020/11/06 Python
CSS3 Notes: -webkit-box-reflect实现倒影的实例
2016/12/08 HTML / CSS
localStorage 设置过期时间的方法实现
2018/12/21 HTML / CSS
Shop Apotheke瑞士:您的健康与美容网上商店
2019/10/09 全球购物
C语言面试题
2015/10/30 面试题
武汉世纪畅想数字传播有限公司.NET笔试题
2014/07/22 面试题
简述安装Slackware Linux系统的过程
2012/01/12 面试题
期末自我鉴定
2014/02/02 职场文书
电子信息专业自荐书
2014/02/04 职场文书
劳资员岗位职责
2015/02/13 职场文书
微信小程序和php的登录实现
2021/04/01 PHP