Home  >  Article  >  Backend Development  >  What does strtotime mean in php?

What does strtotime mean in php?

(*-*)浩
(*-*)浩Original
2019-09-11 15:10:594043browse

strtotime

PHP built-in time function

What does strtotime mean in php?

(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!

Statement:
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