php教程 php手册 php时间戳转换的示例

php时间戳转换的示例

Jun 06, 2016 pm 08:23 PM

PHP获

以下例子得出结果:

复制代码 代码如下:


array(3) { ["yesterday"]=> array(2) { [0]=> int(1395874800) [1]=> int(1395961199) } ["today"]=> array(2) { [0]=> int(1395961200) [1]=> int(1396047599) } ["tomorrow"]=> array(2) { [0]=> int(1396047600) [1]=> int(1396133999) } }

复制代码 代码如下:


//昨天,,今天和明天的日期转换   
//($startstr 今天开始时间戳)
//返回(昨天,今天和明天)的0点和23点59分59秒
function alldaytostr($startstr) {
 $oneday_count = 3600 * 24;  //一天有多少秒
 //明天
 $tomorrow_s = $startstr + $oneday_count;    //明天开始
 $tomorrow_e = $tomorrow_s + $oneday_count - 1;  //明天结束
 //昨天
 $yesterday_s = $startstr - $oneday_count;  //昨天开始
 $yesterday_e = $startstr - 1;   //昨天结束
 //今天结束
 $today_e = $tomorrow_s - 1;
 //昨天、今天和明天 0点和当天23点59分59秒合并成数组
 $allday_array = array('yesterday' => array($yesterday_s, $yesterday_e),
  'today' => array($startstr, $today_e),
  'tomorrow' => array($tomorrow_s, $tomorrow_e));
 return $allday_array;
}
//当天开始时间
$btime = date('Y-m-d'.'00:00:00',time());
//转换成“开始”的时间戳
$btimestr = strtotime($btime);
var_dump(alldaytostr($btimestr));

?>

본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

Video Face Swap

Video Face Swap

완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

뜨거운 도구

메모장++7.3.1

메모장++7.3.1

사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전

SublimeText3 중국어 버전

중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기

스튜디오 13.0.1 보내기

강력한 PHP 통합 개발 환경

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)