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加速的eAccelerator dll支持文件打包下载
Sep 30 PHP
php文章内容分页并生成相应的htm静态页面代码
Jun 07 PHP
url decode problem 解决方法
Dec 26 PHP
PHP.ini中配置屏蔽错误信息显示和保存错误日志的例子
May 12 PHP
php从csv文件读取数据并输出到网页的方法
Mar 14 PHP
功能强大的PHP POST提交数据类
Jul 15 PHP
PHP实现求连续子数组最大和问题2种解决方法
Dec 26 PHP
PHP+MySQL实现消息队列的方法分析
May 09 PHP
PHPStudy下如何为Apache安装SSL证书的方法步骤
Jan 23 PHP
PHP7.3.10编译安装教程
Oct 08 PHP
laravel框架 laravel-admin上传图片到oss的方法
Oct 13 PHP
PHP接口类(interface)的定义、特点和应用示例
May 18 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
在Windows版的PHP中使用ADO
2006/10/09 PHP
PHP输出时间差函数代码
2013/01/28 PHP
ThinkPHP在新浪SAE平台的部署实例
2014/10/31 PHP
对比分析php中Cookie与Session的异同
2016/02/19 PHP
ExtJS 2.0实用简明教程 之Ext类库简介
2009/04/29 Javascript
了解jQuery技巧来提高你的代码
2010/01/08 Javascript
javascript中callee与caller的用法和应用场景
2010/12/08 Javascript
js实现翻页后保持checkbox选中状态的实现方法
2012/11/03 Javascript
JavaScript利用构造函数和原型的方式模拟C#类的功能
2014/03/06 Javascript
jquery 选取方法都有哪些
2014/05/18 Javascript
js如何判断访问是来自搜索引擎(蜘蛛人)还是直接访问
2015/09/14 Javascript
Bootstrap创建可折叠的组件
2016/02/23 Javascript
详解nodejs微信公众号开发——2.自动回复
2017/04/10 NodeJs
vue.js实现条件渲染的实例代码
2017/06/22 Javascript
详解Vue用自定义指令完成一个下拉菜单(select组件)
2017/10/31 Javascript
详解vue项目中使用token的身份验证的简单实践
2019/03/08 Javascript
Vue触发隐藏input file的方法实例详解
2019/08/14 Javascript
解决Vue调用springboot接口403跨域问题
2019/09/02 Javascript
JavaScript十大取整方法实例教程
2020/12/03 Javascript
[53:29]完美世界DOTA2联赛循环赛 DM vs Matador BO2第二场 11.04
2020/11/05 DOTA
[00:59]PWL开团时刻DAY7——我在赶
2020/11/06 DOTA
Python中的一些陷阱与技巧小结
2015/07/10 Python
Diango + uwsgi + nginx项目部署的全过程(可外网访问)
2018/04/22 Python
Python Matplotlib库安装与基本作图示例
2019/01/09 Python
PyCharm中代码字体大小调整方法
2019/07/29 Python
CSS3实现歌词进度文字颜色填充变化动态效果的思路详解
2020/06/02 HTML / CSS
英国领先的电视购物零售商:Ideal World
2019/03/18 全球购物
联强国际笔试题面试题
2013/07/10 面试题
前台文员的岗位职责
2013/11/14 职场文书
商超业务员岗位职责
2014/03/12 职场文书
高等教育专业自荐信范文
2014/03/26 职场文书
社会工作专业求职信
2014/07/15 职场文书
检查机关党的群众路线个人整改措施
2014/10/04 职场文书
婚礼父母答谢词
2015/01/04 职场文书
工厂仓库管理员岗位职责
2015/04/09 职场文书
GoLang中生成UUID唯一标识的实现
2021/05/08 Golang