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
smarty 原来也不过如此~~呵呵
Nov 25 PHP
php pki加密技术(openssl)详解
Jul 01 PHP
PHP网页游戏学习之Xnova(ogame)源码解读(八)
Jun 23 PHP
详解php的socket通信
Aug 11 PHP
分享微信扫码支付开发遇到问题及解决方案-附Ecshop微信支付插件
Aug 23 PHP
Symfony2 session用法实例分析
Feb 04 PHP
php远程下载类分享
Apr 13 PHP
PHP获取input输入框中的值去数据库比较显示出来
Nov 16 PHP
PHP获取当前日期及本周一是几月几号的方法
Mar 28 PHP
PHP微信模板消息操作示例
Jun 29 PHP
gearman中worker常驻后台,导致MySQL server has gone away的解决方法
Feb 27 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 form 表单传参明细研究
2009/07/17 PHP
PHP链接MySQL的常用扩展函数
2014/10/23 PHP
php浏览历史记录的方法
2015/03/10 PHP
[原创]ThinkPHP中SHOW_RUN_TIME不能正常显示运行时间的解决方法
2015/10/10 PHP
PHP语言对接抖音快手小红书视频/图片去水印API接口源码
2020/08/11 PHP
学习YUI.Ext基础第一天
2007/03/10 Javascript
比较详细的javascript对象的property和prototype是什么一种关系
2007/08/06 Javascript
jquery实现每个数字上都带进度条的幻灯片
2013/02/20 Javascript
Javascript实现重力弹跳拖拽运动效果示例
2013/06/28 Javascript
jQuery实现鼠标滑过遮罩并高亮显示效果
2013/07/16 Javascript
js 获取、清空input type=&quot;file&quot;的值(示例代码)
2013/12/24 Javascript
javascript实现checkbox全选的代码
2015/04/30 Javascript
JS基于面向对象实现的放烟花效果
2015/05/07 Javascript
JS组件Bootstrap Table使用实例分享
2016/05/30 Javascript
Bootstrap源码解读网格系统(3)
2016/12/22 Javascript
Webpack框架核心概念(知识点整理)
2017/12/22 Javascript
JavaScript代码实现txt文件的上传预览功能
2018/03/27 Javascript
Vue 之孙组件向爷组件通信的实现
2019/04/23 Javascript
JS中的算法与数据结构之集合(Set)实例详解
2019/08/20 Javascript
微信小程序如何获取地址
2019/12/24 Javascript
python的urllib模块显示下载进度示例
2014/01/17 Python
python的绘图工具matplotlib使用实例
2014/07/03 Python
线程和进程的区别及Python代码实例
2015/02/04 Python
Python正则表达式使用经典实例
2016/06/21 Python
通过python爬虫赚钱的方法
2019/01/29 Python
安全的后院和健身蹦床:JumpSport
2019/07/15 全球购物
Chi Chi London官网:购买连衣裙和礼服
2020/10/25 全球购物
施惠特软件测试面试题以及笔试题
2015/05/13 面试题
产品促销活动策划书
2014/01/15 职场文书
教师旷工检讨书
2014/01/18 职场文书
自主招生专家推荐信
2015/03/26 职场文书
运动会5000米加油稿
2015/07/21 职场文书
追悼会答谢词范文
2015/09/29 职场文书
html+css实现赛博朋克风格按钮
2021/05/26 HTML / CSS
JavaScript中的LHS和RHS分析详情
2022/04/06 Javascript
PostgreSQL 插入INSERT、删除DELETE、更新UPDATE、事务transaction
2022/04/12 PostgreSQL