strtotime
PHP built-in time function
(PHP 4, PHP 5)
strtotime() can create a timestamp of a certain moment in English natural language
Function syntax: int strtotime(string $time[,int $now])
Function: Convert a date and time string in US English format into a unix timestamp.
Function routines (Recommended learning: PHP programming from entry to proficiency)
<?php echo date("Y年n月j日",strtotime("now"));//2010年4月14日 echo date("Y年n月j日",strtotime("8 may 2008"));//2008年5月8日 echo date("Y年n月j日",strtotime("+1 day"));//2010年4月15日 echo date("Y年n月j日",strtotime("last monday"));//2010年4月12日 ?>
Examples
<?php //纪念日倒记时 $time1=strtotime("2010-7-18 9:9:9"); $time2=strtotime("2010-4-18 23:42:10"); $second=$time1-$time2; $year=floor($second/3600/24/365);//年 $temp=$second-$year*365*24*3600; $month=floor($temp/3600/24/30);//月 $temp=$temp-$month*30*24*3600; $day=floor($temp/3600/24);//日 $temp=$temp-$day*3600*24; $hour=floor($temp/3600);//小时 $temp=$temp-$hour*3600; $minute=floor($temp/60);//分 $second1=$temp-$minute*60;//秒 echo "距离培训毕业还有".$year."年".$month."月".$day."天".$hour."小时".$minute."分".$second1."秒"; ?>
The above is the detailed content of What does strtotime mean in php?. For more information, please follow other related articles on the PHP Chinese website!

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

SublimeText3 English version
Recommended: Win version, supports code prompts!

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

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

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

WebStorm Mac version
Useful JavaScript development tools
