zoukankan      html  css  js  c++  java
  • php 获取系统时间

    转自“http://www.cnblogs.com/hailexuexi/archive/2010/10/09/1846440.html”

    php 获取系统时间

    <?php   
    echo   date("Y-m-d   h:i:s");   
    ?>   

    <?php

    date_default_timezone_set('Asia/Chongqing'); //系统时间差8小时问题
    $now = getdate(time()); 
    $cur_wday=$now['wday'];
    $date = date("Y-m-d H:i:s $cweekday[$cur_wday]"); 
    echo $date;

     ?>

    具体字母代表的含义:


    a   -   "am"   或   "pm"     
        
    A   -   "AM"   或   "PM"     
        
    B   -   Swatch   Internet   Time     
        
    d   -   月份中的第几天,有前导零的   2   位数字,例如   "01"   to   "31"     
        
    D   -   星期中的第几天,文本表示,3   个字母,例如   "Fri"     
        
    F   -   月份,完整的文本格式,例如   "January"     
        
    g   -   小时,12   小时格式,没有前导零,例如   "1"   到   "12"     
        
    G   -   小时,24   小时格式,没有前导零,例如   "0"   到   "23"     
        
    h   -   小时,12   小时格式,例如   "01"   到   "12"     
        
    H   -   小时,24   小时格式,例如   "00"   到   "23"     
        
    i   -   分钟,例如   "00"   到   "59"     
        
    I(“i”的大写的字母)-   如果是夏令时则为   "1",否则为   "0"     
        
    j   -   月份中的第几天,没有前导零,例如   "1"   到   "31"     
        
    l(“L”的小写字母)-   星期中的第几天,完整的文本格式,例如   "Friday"     
        
    L   -   布尔值表示是否为闰年,例如   "0"   或者   "1"     
        
    m   -   月份,例如   "01"   to   "12"     
        
    M   -   月份,文本表示,3   个字母,例如   "Jan"     
        
    n   -   月份,没有前导零,例如   "1"   到   "12"     
        
    O   -   与格林威治时间相差的小时数,例如   "+0200"     
        
    r   -   RFC   822   格式的日期,例如   "Thu,   21   Dec   2000   16:01:07   +0200"(PHP   4.0.4新增)     
        
    s   -   秒数,例如   "00"   到   "59"     
        
    S   -   每月天数后面的英文后缀,2   个字符,例如   "st","nd","rd"   或者   "th"     
        
    t   -   给定月份所应有的天数,例如   "28"   到   "31"     
        
    T   -   本机所在的时区,例如   "EST"   或   "MDT"(【译者注】在   Windows   下为完整文本格式,例如“Eastern   Standard   Time”,中文版会显示“中国标准时间”。)     
        
    U   -   从   Unix   纪元(January   1   1970   00:00:00   GMT)开始至今的秒数     
        
    w   -   星期中的第几天,数字表示,例如   "0"(星期天)到   "6"   (Saturday)     
        
    W   -   ISO-8601   格式年份中的第几周,每周从星期一开始(PHP   4.1.0   新加的)     
        
    Y   -   年份,4   位数字,例如   "1999"     
        
    y   -   年费,2   位数字,例如   "99"     
        
    z   -   年份中的第几天,例如   "0"   到   "365"     
        
    Z   -   时差偏移量的秒数(例如   "-43200"   到   "43200")。UTC   西边的时区偏移量总是负的,UTC   东边的时区偏移量总是正的。    

  • 相关阅读:
    用wamp配置的环境,想用CMD连接mysql怎么连
    Mysql删除表
    MySQL创建表
    Leetcode 130. Surrounded Regions
    Leetcode 111. Minimum Depth of Binary Tree
    Leetcode 110. Balanced Binary Tree
    Leetcode 98. Validate Binary Search Tree
    Leetcode 99. Recover Binary Search Tree
    Leetcode 108. Convert Sorted Array to Binary Search Tree
    Leetcode 105. Construct Binary Tree from Preorder and Inorder Traversal
  • 原文地址:https://www.cnblogs.com/ftrako/p/5184043.html
Copyright © 2011-2022 走看看