php强大的时间转换函数strtotime,php函数strtotime
使用strtotime可以将各种格式的时间字符串转换为时间戳
转换常规时间格式
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;
转换自然时间描述
//昨天 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;
完整的php时间描述文档可以参考 http://php.net/manual/zh/datetime.formats.relative.php
您可能感兴趣的文章:
- PHP strtotime函数详解
- php 深入理解strtotime函数的使用详解
- PHP时间戳 strtotime()使用方法和技巧
- php使用strtotime和date函数判断日期是否有效代码分享
- PHP下获取上个月、下个月、本月的日期(strtotime,date)
- php使用date和strtotime函数输出指定日期的方法
- js模仿php中strtotime()与date()函数实现方法
- PHP使用strtotime获取上个月、下个月、本月的日期

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Zend Studio 13.0.1
Powerful PHP integrated development environment

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
