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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Linux new version
SublimeText3 Linux latest version

Atom editor mac version download
The most popular open source editor

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.

SublimeText3 Mac version
God-level code editing software (SublimeText3)