免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1367 | 回复: 0
打印 上一主题 下一主题

localtime() 函数 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-09-11 17:03 |只看该作者 |倒序浏览
1、Definition and Usage
定义和用法

The localtime() function returns an array that contains the time components of a Unix timestamp.
localtime()函数的作用是:以数组的形式返回本地时间。
2、Syntax
语法

localtime(timestamp,is_associative)
Parameter参数
Description描述
timestamp
Optional. Specifies the date or time to be formatted. If no timestamp is specified, it uses the current local time.
可选参数。指定需要被定义的日期和时间。如果没有指定时间戳,那么它将默认使用本地时间。
is_associative
Optional. Specifies whether to return an associative or indexed array. If set to false the array returned is an indexed array. If set to true then the array returned is an associative array.
可选参数。指定是否返回一个联合数组[associative array]或索引数组[indexed array]。如果设置为False,则返回一个索引数组;如果设置为True,则返回一个联合数组:
The keys of the associative array are:
联合数组的关键词如下:

  • [tm_sec] - seconds
    [tm_sec] – 秒
  • [tm_min] - minutes
    [tm_min] – 分钟
  • [tm_hour] - hour
    [tm_hour] – 小时
  • [tm_mday] - day of the month
    [tm_mday] – 月份中的天数
  • [tm_mon] - month of the year (January=0)
    [tm_mon] – 一年中的月份(January=0)
  • [tm_year] - Years since 1900
    [tm_year] – 从1900年开始的年份
  • [tm_wday] - Day of the week (Sunday=0)
    [tm_wday] – 用数字表示星期几(Sunday=0)
  • [tm_yday] - Day of the year
    [tm_yday] – 表示一年中的星期几
  • [tm_isdst] - Is daylight savings time in effect
    [tm_isdst] – 判断是否是夏令时

3、举例
Example
案例
Example without and with associative arrays:
包含/不包含联合数组的情况:
The output of the code above could be:
上述代码将输出下面的结果:
Array
(
[0] => 28
[1] => 35
[2] => 13
[3] => 25
[4] => 0
[5] => 106
[6] => 3
[7] => 24
[8] => 0
)Array
(
[tm_sec] => 28
[tm_min] => 35
[tm_hour] => 13
[tm_mday] => 25
[tm_mon] => 0
[tm_year] => 106
[tm_wday] => 3
[tm_yday] => 24
[tm_isdst] => 0
)


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/45525/showart_379660.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP