Home > Backend Development > PHP Tutorial > PHP's powerful time conversion function strtotime_php skills

PHP's powerful time conversion function strtotime_php skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 19:58:17
Original
1221 people have browsed it

Use strtotime to convert time strings in various formats into timestamps

Convert regular time format

echo date('Y-m-d H:i:s', strtotime('2016-01-30 18:00')).PHP_EOL;
echo date('Y-m-d H:i:s', strtotime('20160130180001')).PHP_EOL;
 
Copy after login

Convert natural time description

//昨天
echo date('Y-m-d H:i:s', strtotime('yesterday')).PHP_EOL;
//上周
echo date('Y-m-d H:i:s', strtotime('last week')).PHP_EOL;
//本周开始时间
echo date('Y-m-d H:i:s', strtotime('this week midnight')).PHP_EOL;
//本月开始时间
echo date('Y-m-d H:i:s', strtotime('first day of this month midnight')).PHP_EOL;
 
//计算相对时间
echo date('Y-m-d H:i:s', strtotime('+1 month')).PHP_EOL;
Copy after login

For the complete php time description document, please refer to http://php.net/manual/zh/datetime.formats.relative.php

Related labels:
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template