How to convert time format in php

L
Release: 2023-03-01 11:24:02
Original
3399 people have browsed it

How to convert time format in php

php time format conversion

Convert seconds to hours, minutes and seconds

function cktime($billsec){
  $cktime = '';
  if($billsec>'0'){
    $cktime = gmstrftime('%H:%M:%S',$billsec);
  }
  return $cktime;
}
Copy after login

Generate the current time Stamp and display the time in the format

$time = time();//获取时间戳
$nowtime = date('Y-m-d H:i:s',$time);//生成规定的时间格式
Copy after login

Convert the exact event to a timestamp

$oldtime = '2010-11-10 22:19:21'; 
$catime = strtotime($oldtime);
Copy after login

Print the timestamp at this time tomorrow

strtotime(”+1 day“)
Copy after login

Print the time stamp at this time yesterday

strtotime(”-1 day“)
Copy after login

Print the timestamp of next week at this time

strtotime(”+1 week“)
Copy after login

Print the PHP timestamp of the specified day of next week

strtotime(”next Thursday“)
Copy after login

Print the timestamp of the specified day of last week

strtotime(”last Thursday“)
Copy after login

Recommended tutorial: "PHP tutorial"

The above is the detailed content of How to convert time format in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template