位置: 编程技术 - 正文

PHP:mktime()的用法_Date Time函数(php使用memcache)

编辑:rootadmin
mktime

推荐整理分享PHP:mktime()的用法_Date Time函数(php使用memcache),希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:phpmkdir,mktime php,php mktime函数,php time,php使用memcache,phpmkdir,php中mkdir,php time,内容如对您有帮助,希望把文章链接给更多的朋友!

(PHP 4, PHP 5)

mktime — 取得一个日期的 Unix 时间戳

说明 int mktime ([ int $hour = date("H") [, int $minute = date("i") [, int $second = date("s") [, int $month = date("n") [, int $day = date("j") [, int $year = date("Y") [, int $is_dst = -1 ]]]]]]] )

根据给出的参数返回 Unix 时间戳。时间戳是一个长整数,包含了从 Unix 纪元(January 1 :: GMT)到给定时间的秒数。

参数可以从右向左省略,任何省略的参数会被设置成本地日期和时间的当前值。

注释

Note:

As of PHP 5.1, when called with no arguments, mktime() throws an E_STRICT notice: use the time() function instead.

参数

hour

小时数。 The number of the hour relative to the start of the day determined by month, day and year. Negative values reference the hour before midnight of the day in question. Values greater than reference the appropriate hour in the following day(s).

minute

分钟数。 The number of the minute relative to the start of the hour. Negative values reference the minute in the previous hour. Values greater than reference the appropriate minute in the following hour(s).

second

秒数(一分钟之内)。 The number of seconds relative to the start of the minute. Negative values reference the second in the previous minute. Values greater than reference the appropriate second in the following minute(s).

month

月份数。 The number of the month relative to the end of the previous year. Values 1 to reference the normal calendar months of the year in question. Values less than 1 (including negative values) reference the months in the previous year in reverse order, so 0 is December, -1 is November, etc. Values greater than reference the appropriate month in the following year(s).

day

天数。 The number of the day relative to the end of the previous month. Values 1 to , , or (depending upon the month) reference the normal days in the relevant month. Values less than 1 (including negative values) reference the days in the previous month, so 0 is the last day of the previous month, -1 is the day before that, etc. Values greater than the number of days in the relevant month reference the appropriate day in the following month(s).

year

年份数,可以是两位或四位数字,0- 对应于 -,- 对应于 -。在如今系统中普遍把 time_t 作为一个 位有符号整数的情况下,year 的合法范围是 到 之间,不过此限制自 PHP 5.1.0 起已被克服了。

is_dst

本参数可以设为 1,表示正处于夏时制时间(DST),0 表示不是夏时制,或者 -1(默认值)表示不知道是否是夏时制。如果未知,PHP 会尝试自己搞明白。这可能产生不可预知(但并非不正确)的结果。如果 PHP 运行的系统中启用了 DST 或者 is_dst 设为 1,某些时间是无效的。例如 DST 自 2: 生效,则所有处于 2: 到 3: 之间的时间都无效,mktime() 会返回一个未定义(通常为负)的值。某些系统(例如 Solaris 8)的 DST 在午夜生效,则 DST 生效当天的 0: 会被计算为前一天的 :。

PHP:mktime()的用法_Date Time函数(php使用memcache)

Note:

自 PHP 5.1.0 起,本参数已被废弃。应该使用新的时区处理特性来替代。

返回值

mktime() 根据给出的参数返回 Unix 时间戳。如果参数非法,本函数返回 FALSE(在 PHP 5.1 之前返回 -1)。

错误/异常

在每 次调用日期/时间函数时,如果时区无效则会引发 E_NOTICE 错误,如果使用系统设定值或 TZ环境变量,则会引发 E_STRICT 或 E_WARNING 消息。参见date_default_timezone_set()。

更新日志

版本 说明 5.3.0 mktime() now throws E_DEPRECATED notice if the is_dst parameter is used. 5.1.0 is_dst 参数被废弃。出错时函数返回 FALSE 而不再是 -1。修正了本函数可以接受年月日参数全为零。 5.1.0 When called with no arguments, mktime() throws E_STRICT notice. Use the time() function instead. 5.1.0

现在发布 E_STRICT 和 E_NOTICE时区错误。

范例

Example #1 基本例子

<?php//Setthedefaulttimezonetouse.AvailableasofPHP5.1date_default_timezone_set('UTC');//Prints:July1,isonaSaturdayecho"July1,isona".date("l",mktime(0,0,0,7,1,));//Printssomethinglike:--T::+:echodate('c',mktime(1,2,3,4,5,));?>

Example #2 mktime() 例子

mktime() 在做日期计算和验证方面很有用,它会自动计算超出范围的输入的正确值。例如下面例子中每一行都会产生字符串 "Jan--"。

<?phpechodate("M-d-Y",mktime(0,0,0,,,));echodate("M-d-Y",mktime(0,0,0,,1,));echodate("M-d-Y",mktime(0,0,0,1,1,));echodate("M-d-Y",mktime(0,0,0,1,1,));?>

Example #3 下个月的最后一天

任何给定月份的最后一天都可以被表示为下个月的第 "0" 天,而不是 -1 天。下面两个例子都会产生字符串 "The last day in Feb is: "。

<?php$lastday=mktime(0,0,0,3,0,);echostrftime("LastdayinFebis:%d",$lastday);$lastday=mktime(0,0,0,4,-,);echostrftime("LastdayinFebis:%d",$lastday);?>

注释 Caution

在 PHP 5.1.0 之前,在任何已知 Windows 版本以及一些其它系统下不支持负的时间戳。因此年份的有效范围限制为 到 。

参见

checkdate() - 验证一个格里高里日期 gmmktime() - 取得 GMT 日期的 UNIX 时间戳 date() - 格式化一个本地时间/日期 time() - 返回当前的 Unix 时间戳

PHP:microtime()的用法_Date Time函数 microtime(PHP4,PHP5)microtime返回当前Unix时间戳和微秒数说明mixedmicrotime([bool$get_as_float])microtime()当前Unix时间戳以及微秒数。本函数仅在支持gettimeofday()系统调

PHP:localtime()的用法_Date Time函数 localtime(PHP4,PHP5)localtime取得本地时间说明arraylocaltime([int$timestamp=time()[,bool$is_associative=false]])localtime()函数返回一个数组,其结构和C函数调用返回的完全一

PHP:date()的用法_Date Time函数 date(PHP4,PHP5)date格式化一个本地时间/日期说明stringdate(string$format[,int$timestamp])返回将整数timestamp按照给定的格式字串而产生的字符串。如果没有给出时

标签: php使用memcache

本文链接地址:https://www.jiuchutong.com/biancheng/287360.html 转载请保留说明!

上一篇:PHP:strptime()的用法_Date Time函数(php stl)

下一篇:PHP:microtime()的用法_Date Time函数(php time)

  • 企业税前扣除凭证包括增值税发票吗
  • 建筑安装增值税纳税地点
  • 资产减值损失影响利润吗
  • 投资性房地产出售时公允价值变动损益
  • 新个税法申报的税种
  • 招标押金如何做账务处理?
  • 去年的电费可以在今年入账分录
  • 眼镜所属行业怎么填写
  • 对赌协议赢了怎么样
  • 补开发票怎么做分录?
  • 损益类科目计入哪个表
  • 建安企业无收入怎么结转成本?
  • 工厂没给工人买保险会被处罚吗?
  • 公司名字开错了,认证过了怎么处理
  • 建筑业简易征收的适用范围
  • 个人税务代人开普票
  • 小微企业所得税税率多少
  • 资产总额季初和季末
  • 注册资金印花税什么时候开始交
  • 注册资金印花税怎么算
  • 增值税进项转出后企业所得税调整是含税价还是不含税价
  • 小规模纳税人的增值税账务处理
  • 申请出具商标注意事项
  • 汽车销售公司购买车辆会计科目
  • win11更新22468
  • 小米6桌面图标消失了
  • 本期用于购建不动产的扣税凭证怎么填
  • 苹果推送ios15
  • js时间格式转换时间戳
  • islp2sta.exe - islp2sta是什么进程 有什么作用
  • 接受专利投资会亏本吗
  • 出售固定资产申报表收入与损益表收入不一致
  • vue.js前端开发快速入门与专业应用
  • laravel实现登录注册
  • php的了解
  • uniapp中使用amap-vue,设置安全密钥
  • Android ImageView使用详解(系列教程三)
  • 不得从销项税额中抵扣的是
  • 固定资产折旧应计入什么费用
  • 独资子公司与母公司
  • 上传图片php
  • java 类型推导
  • 限售股 缴税
  • 织梦图集的使用教程
  • 原始凭证可以外带吗
  • 联营企业有重大影响吗
  • 库存股会计处理流程
  • 财务费用报销流程最后环节出纳
  • 外出经营必须办理外管证吗
  • 建筑公司异地施工
  • 残保金未交,滞纳金怎么算
  • 开发票的销售收入正规的做账如何做?
  • 收到待报解预算收入是国家退的税吗
  • 业务招待费比例控制规定
  • 单位交社保怎么取消居民医保
  • 为别人开发票先收的税金怎么入帐?
  • 公司车还车贷计入什么科目
  • 现金流动负债比率越大越好吗
  • 自然人独资公司税收政策
  • 个人出租租房收什么税
  • 美国支票上的收款人地址不对怎么办
  • 留抵税额可以抵欠税吗
  • 施工企业其他业务收入包括哪些
  • 好用的sql工具
  • winxp系统怎么设置默认账户登入
  • centos获取权限
  • 深入分析南水北调工程面临的新形势心得体会
  • nodejs bull
  • python批量下载文件
  • css美化表单 案例
  • node.js中的http.response.removeHeader方法使用说明
  • 2012年腾讯股价多少
  • mongoose教程
  • android 按键
  • jquery 扩展事件
  • js给input添加属性
  • 贵州省地方税务局历任纪检组长马平
  • 临时税务登记纳税有区域限制吗为什么
  • 中国税务网官网1732171695993732.2418.61431871
  • 金税盘和uk
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

    网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

    友情链接: 武汉网站建设