Time conversion function in 1.php
Strtotime ("Today")
Date ("Y-m-d h:i", $unixtime)
2.php to get today's 0-point time stamp
To get a 0-point Unix timestamp, you can use $todaytime=strtotime ("Today"),
Then use Date ("Y-m-d h:i", $todaytime) to convert to a date.
3.php timestamp to date, and display different content according to time, such as just, minutes ago, hours ago, today, yesterday, etc.
/* Time conversion function * *
function Transtime ($ustime) {
$ytime = Date ("y-m-d h:i", $ustime);
$rtime = Date ("N-month J-day H:i", $ustime);
$htime = Date ("H:i", $ustime);
$time = Time ()-$ustime;
$todaytime = Strtotime ("Today");
$time 1 = time ()-$todaytime;
if ($time < 60) {
$str = ' just ';
}else if ($time < 60 * 60) {
$min = Floor ($time/60);
$str = $min. ' Minutes ago ';
}else if ($time < $time 1) {
$str = ' Today '. $htime;
}else{
$str = $rtime;
}
return $str;
}
In this function you can add more comparisons to make the displayed date more specific, such as adding seconds before the day before yesterday and more specific dates.
4.php Date with 0 and no supplement 0
echo Date (' y-m-d '); Show 2012-08-08
echo Date (' y-n-j '); Show 2012-8-8