Home > php教程 > php手册 > 常用PHP日期处理函数

常用PHP日期处理函数

WBOY
Release: 2016-06-06 19:35:17
Original
1350 people have browsed it

个人原创网址:http://www.phpthinking.com/archives/330 常用PHP日期处理函数 PHP 开发过程中,常用日期处理函数,时间戳处理函数等,如下讲解:?phpecho date('Y-m-d h:i:s',time());//运行结果(年月日时分秒,“-”间隔):2014-09-12 06:28:32echo date('Y

个人原创网址: http://www.phpthinking.com/archives/330

常用PHP日期处理函数 PHP
开发过程中,常用日期处理函数,时间戳处理函数等,如下讲解:
<?php
echo date('Y-m-d h:i:s',time());

//运行结果(年月日时分秒,“-”间隔):2014-09-12 06:28:32

echo date('Y-m-d',time());

//运行结果(年月日,“-”间隔):2014-09-12

echo date('Y-m-d',strtotime(date('Y-m-d', time()-86400)));

//运行结果(当前日期前一天的年月日,“-”间隔):2014-09-11

echo date('Ymd',time());

//运行结果(年月日,无间隔):20140912

echo date('m-d',time());

//运行结果(月日,“-”间隔):09-12

echo str_replace("-","月",date('m-d',time()-date('w',time())*86400))."日";

//运行结果(月日,汉字显示间隔):09月12日

echo date('w',time());

//运行结果(星期几):5

echo time();

//运行结果(当前日期时间的秒数):1410503809

echo strtotime(date('Y-m-d',time()));

//运行结果(当前日期秒数,具体到天):1410503809

echo date('Y-m-d',strtotime(date('Y-m-d', time()))-date('w',strtotime(date('Y-m-d', time())))*86400);

//运行结果(当前日期所属自然周的起始日期即周日的日期,具体到天,“-”间隔):2014-09-07
Copy after login
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