歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Unix知識 >> 關於Unix >> strtotime將文本日期時間解析為Unix時間戳

strtotime將文本日期時間解析為Unix時間戳

日期:2017/2/28 11:25:18   编辑:關於Unix



CODE:<?php
echo strtotime("2006-01-09");
echo strtotime("2006-01-09 08:10");
echo strtotime("now");
echo strtotime("10 September 2000");
echo strtotime("+1 day");
echo strtotime("+1 week");
echo strtotime("+1 week 2 days 4 hours 2 seconds");
echo strtotime("next Thursday");
echo strtotime("last Monday");
?>

.今日日期號
CODE:$days=date('d',strtotime('now')); //2006-09-06

.當前月月初
CODE:echo $currMBegin=date("Y-m", strtotime('now'))."-01 &nbsp;";

.本月月末
CODE:echo $currMEnd =date("Y-m-d", strtotime("next month -$days day"));

.下月月初
CODE:echo $nextMBegin=date("Y-m", strtotime('next month'))."-01";

.下月月底
CODE:echo $nextMEnd =date("Y-m-d", strtotime("+2 months -$days day"));

2006-09-01 2006-09-30
2006-10-01 2006-10-31
Copyright © Linux教程網 All Rights Reserved