Home > php教程 > php手册 > body text

php strtotime()函数日期转换应用实例

WBOY
Release: 2016-05-25 16:44:30
Original
1422 people have browsed it

今天没事在研究一个功能但会用到strtotime函数了,这个我是把2014-07-8 0:0:0格式的转换时间戳了,这个例子非常的好用,下面来看个例子吧。

实现功能

获取当半时间与用户给定的时间进行对比,然后判断是几天之内进行相关操作了

程序代码

<?php
$d = &#39;2014-01-09&#39;;
$time = time();
$ftime = strtotime(&#39;2014-07-8 0:0:0&#39;);
echo $ftime;
echo date(&#39;Y-m-d&#39;, $ftime) . &#39;<br />&#39;;
if (round(($time - $ftime) / 86500, 1) < 7) // 7天之内不允许复制
{
    echo &#39;7 stop copy&#39;;
} else {
    echo &#39;good&#39;;
}
?>
Copy after login

php入门网应用于一些比较简单的内容处理上了,在此我就不说出来了免得大得进行攻击我的网哦哈。


文章链接:

随便收藏,请保留本文地址!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!