zoukankan      html  css  js  c++  java
  • php 时间日期

    1. echo date('Y-m-d H:i:s');

    date_default_timezone_set('PRC'); 设定时区
    echo date_default_timezone_get();获取服务器设定的时区信息
    创建函数返回时间戳mktime(1,2,22,1,5,2015)
    1. echo mktime(1,2,22,1,5,2015).'<br>';
    2. echo date('Y-m-d H:i:s',1420390942);

    time()获取当前系统的时间戳,
    1. echo time();
    2. echo date('Y-m-d H:i:s',1431697515);

    strtotime('1983-1-1') 将日期字符串转换为 数字的时间戳
    1. $time=strtotime('1983-1-1');
    2. echo $time.'<br>';
    3. echo date('Y年m月d日',410198400);

    trtotime('+2 day') 返回2天后的时间戳
    1. echo strtotime('+2 day').'<br>';
    2. echo date('Y-m-d H:i:s',1431871146);

    统计留言时间
    1. $time="2015-5-15 22:17:1";
    2. $t=strtotime($time);//输出$time的时间戳
    3. $now=time(); //输出现在时间的时间戳
    4. $rr=floor(($now-$t)/86400);//floor 表示取整数 $rr 表示现在距离留言时间的时间差为多少
    5. $hh=floor(($now-$t)/3600);
    6. $mm=floor(($now-$t)/60);
    7. $ss=floor($now-$t);
    8. if($rr>=30){
    9. echo "留言时间为:$time";
    10. }else if($rr>=1){
    11. echo $rr.'天前';
    12. }else if($hh>=1){
    13. echo $hh.'小时前';
    14. }else if($mm>=1){
    15. echo $mm.'分钟前';
    16. }else{
    17. echo $ss.'秒前';
    18. }

    统计7天以内的会员注册信息
    select count(*) from member where regtime between strtotime('-7 day')and time();







  • 相关阅读:
    MP教程-入门
    [15213] Assembly
    Crack the code interview
    [interview questions] 资料总结
    [Two Sigma OA] Longest Chain
    [Tow Sigma OA] friend cycles
    [security]
    [security] GNUpg
    [coursera] 面试前准备
    [coursera] [design] Hangman
  • 原文地址:https://www.cnblogs.com/lsr111/p/4506952.html
Copyright © 2011-2022 走看看