php 时间转化函数实例
php中日期转换函数strtotime的用法:
语法:
int strtotime ( string time [, int now] )
返回将任何英文文本的日期时间描述解析为 Unix 时间戳
实例:
一,获取指定日期的unix时间戳 strtotime("2009-1-22") 示例如下:
echo strtotime("2009-1-22") 结果:1232553600
说明:返回2009年1月22日0点0分0秒时间戳
二,获取英文文本日期时间 示例如下:
便于比较,使用date将当时间戳与指定时间戳转换成系统时间
(1)打印明天此时的时间戳strtotime("+1 day")
当前时间:echo date("Y-m-d H:i:s",time()) 结果:2009-01-22 09:40:25
指定时间:echo date("Y-m-d H:i:s",strtotime("+1 day")) 结果:2009-01-23 09:40:25
(2)打印昨天此时的时间戳strtotime("-1 day")
当前时间:echo date("Y-m-d H:i:s",time()) 结果:2009-01-22 09:40:25
指定时间:echo date("Y-m-d H:i:s",strtotime("-1 day")) 结果:2009-01-21 09:40:25
(3)打印下个星期此时的时间戳strtotime("+1 week")
当前时间:echo date("Y-m-d H:i:s",time()) 结果:2009-01-22 09:40:25
指定时间:echo date("Y-m-d H:i:s",strtotime("+1 week")) 结果:2009-01-29 09:40:25
(4)打印上个星期此时的时间戳strtotime("-1 week")
当前时间:echo date("Y-m-d H:i:s",time()) 结果:2009-01-22 09:40:25
指定时间:echo date("Y-m-d H:i:s",strtotime("-1 week")) 结果:2009-01-15 09:40:25
(5)打印指定下星期几的时间戳strtotime("next Thursday")
当前时间:echo date("Y-m-d H:i:s",time()) 结果:2009-01-22 09:40:25
指定时间:echo date("Y-m-d H:i:s",strtotime("next Thursday")) 结果:2009-01-29 00:00:00
(6)打印指定上星期几的时间戳strtotime("last Thursday")
当前时间:echo date("Y-m-d H:i:s",time()) 结果:2009-01-22 09:40:25
指定时间:echo date("Y-m-d H:i:s",strtotime("last Thursday")) 结果:2009-01-15 00:00:00
以上示例可知,strtotime能将任何英文文本的日期时间描述解析为Unix时间戳,我们结合mktime()或date()格式化日期时间获取指定的时间戳,实现所需
相关文档:
Memcache函数库是在PECL(PHP Extension Community Library)中,主要作用是搭建大容量的内存数据的临时存放区域,在分布式的时候作用体现的非常明显,否则不建议使用。
memcache函数所有的方法列表如下:
参考http://www.php.net/manual/zh/function.Memcache-add.php
Memcache::add - 添加一个值,如果已经存在,则返回f ......
近日在用自己以前写的http下载器下载某一个php页面以外遭遇403错误.但是ie却能够正确访问. 日志如下: IE: Time At:0005504671
Line:10
send: 192.168.1.2 –> xxx.xxx.xxx.xxx len:351
GET /test.jpg HTTP/1.1
Accept: */*
Accept-Language: en-us
Accept-Enc ......
作者:http://blog.csdn.net/zhoufoxcn/archive/2009/11/05/4769858.aspx
说明:因为最近工作工作关系,需要开发一个在Linux下运行的Web
Application,需要对现在比较流行的一些PHP框架做一个了解和评估,下面的这篇文章是笔者最近学习一个比较新的PHP
Framework的一点经历和操作步骤,因为官方的手册写得比较晦 ......
整理自:http://bbs.phpchina.com/viewthread.php?tid=18006
文件a.txt,用PHP如何判断它的编码是GBK还是UTF-8呢?
1,重新认识一下此问题,当时版主回复的时候我就觉得mb函数里一定有这样的功能,但今日研究了mb库,并没有这样的功能。用mb_detect_encoding总是不准确。
echo mb_detect_encoding(file_get_conten ......
PHP的JSON类库我使用的是Services_JSON
,没什么特别的优点,也没什么明显的缺点,对付用足矣。
建立文件data.php
:
<?php
include(
"JSON.php"
);
$data
= array(
array(
'name'
=>
mb_convert_encoding
(
'老王'
,
'UTF-8'
,
'GBK'
), ......