strtotime ("10 September 2000");  转换这个时间为时间戳
date("Y-m-d",time());  将时间戳转换为Y-m-d这样的时间格式你想得到什么样呢?

解决方案 »

  1.   

    参考吧!
    http://expert.csdn.net/Expert/topic/1890/1890618.xml?temp=.9336969
    可以转化成你需要的.
      

  2.   

    date("y年m月d日H时I分S秒",time());
    date("y年m月d日",time());
    试试就知道了。
      

  3.   

    $time=data(yy-mm-dd ii:ss)
    将显示98-01-11 14:00
      

  4.   

    不好意思,看来我没把问题说清楚:是这样的,我用的数据库是SQLServe2k,其中有一个日期时间格式的数据od_DateTime,显示数据正常为“2003-06-06 13:44:50.507”,但是在php中调用mssql_fetch_row函数执行sql查询语句后显示出的数据中却出现了中文,为“$d1=2003 六月 6 13:44”。我希望最后出现在界面上的形式为“2003-06-06”,因此,我使用了如下语句:
    “date("Y-m-d",strtotime($d1)”,但最后出现的确是当前时间,非数据库时间。我觉得问题可能出现在php查询后出现的中文问题,但不知如何解决。大家以为如何?谢谢。
      

  5.   

    在查询的时候用convert函数即可:
    $query="select convert(char,createddate,102) as createddate from users where netid=$netid"; //得到的日期为2003.06.06;
    ......//将2002.06.06转换为2003-06-06;
    $Y=substr($row[0],0,4);
    $M=substr($row[0],5,2);
    $D=substr($row[0],8,2);
    $dl=$Y."-".$M."-".$D;convert数据库的日期格式转换参考:
    select convert(char(20),getdate(),101)
    select emp_id,convert(char(20),hire_dt,101) from employee
    -----------------------------------------------------日期格式 代号
    -------------------- -----------
    04/05/2000 101-------------------- -----------
    2000.04.05 102-------------------- -----------
    05/04/2000 103-------------------- -----------
    05.04.2000 104-------------------- -----------
    05-04-2000 105-------------------- -----------
    05 Apr 2000 106-------------------- -----------
    Apr 05, 2000 107-------------------- -----------
    11:33:24 108-------------------- -----------
    Apr 5 2000 11:33:24 109-------------------- -----------
    04-05-2000 110-------------------- -----------
    2000/04/05 111-------------------- -----------
    20000405 112  -------------------- -----------
    11:33:24:000  114
    -------------------- -----------
    19 04 2003 00:00:00:       113
      

  6.   

    select convert(char,od_DateTime,120) ....
      

  7.   

    哦,还不知道有个代号为120
    学习ing...
      

  8.   

    哦,看一下SQL online help,呵呵
      

  9.   

    http://www.chinalinuxpub.com/doc/database/mysql_manual/manual_toc.html