mktime()和time()有什么区别?

解决方案 »

  1.   

    gmstrftime()返回的是格林威治标准时,我们在东八区,要加8。
      

  2.   

    time()返回的是当前的unix时间戳,mktime()可以等到任意时间的时间戳。
      

  3.   

    获取当前系统时间可以直接用
    date('Y-m-d H:i:s');
      

  4.   

    <?php
    echo '格林威治时间'.gmstrftime('%Y-%m-%d %H:%M:%S', time());
    echo '<br>';
    echo '北京时间'.strftime('%Y-%m-%d %H:%M:%S', time());
    ?>
      

  5.   

    范例一:
    <?
    print(date( "l dS of F Y h:i:s A" ));
    print("July 1, 2000 is on a " . date("l", mktime(0,0,0,7,1,2000)));
    ?>范例二:
    <?
    $tomorrow  = mktime(0,0,0,date("m")  ,date("d")+1,date("Y"));
    $lastmonth = mktime(0,0,0,date("m")-1,date("d"),  date("Y"));
    $nextyear  = mktime(0,0,0,date("m"),  date("d",   date("Y")+1);
    ?> 
      

  6.   

    date('Y年m月d日 H:i:s');