WebLinuxStudy

导航

 
<?php
header("Content-Type:text/html;charset=UTF-8");
date_default_timezone_set("Asia/Shanghai");

//1、当前时间戳
echo ' ----- 当前时间戳 ----- ' . '<br>';
echo 'time()' . '<br>';
echo time() . '<br>';
echo date('Y-m-d H:i:s', time()) . '<br>' . '<br>';

echo 'strtotime(\'now\')' . '<br>';
echo strtotime('now') . '<br>';
echo date('Y-m-d H:i:s', strtotime('now')) . '<br>' . '<br>';

//2、当天0点0分0秒的时间戳
echo ' ----- 当天0点0分0秒的时间戳 ----- ' . '<br>';
echo 'strtotime(\'today\')' . '<br>';
echo strtotime('today') . '<br>';
echo date('Y-m-d H:i:s', strtotime('today')) . '<br>' . '<br>';

//3、昨天0点0分0秒的时间戳
echo ' ----- 昨天0点0分0秒的时间戳 ----- ' . '<br>';
echo 'strtotime(\'yesterday\')' . '<br>';
echo strtotime('yesterday') . '<br>';
echo date('Y-m-d H:i:s', strtotime('yesterday')) . '<br>' . '<br>';

//4、一天前(即24小时前)的时间戳
echo ' ----- 一天前(即24小时前)的时间戳 ----- ' . '<br>';
echo 'strtotime(\'1 day ago\')' . '<br>';
echo strtotime('1 day ago') . '<br>';
echo date('Y-m-d H:i:s', strtotime('1 day ago')) . '<br>' . '<br>';

echo 'strtotime(\'1 days ago\')' . '<br>';
echo strtotime('1 days ago') . '<br>';
echo date('Y-m-d H:i:s', strtotime('1 days ago')) . '<br>' . '<br>';

echo 'strtotime(\'-1 day\')' . '<br>';
echo strtotime('-1 day') . '<br>';
echo date('Y-m-d H:i:s', strtotime('-1 day')) . '<br>' . '<br>';

echo 'strtotime(\'-1 days\')' . '<br>';
echo strtotime('-1 days') . '<br>';
echo date('Y-m-d H:i:s', strtotime('-1 days')) . '<br>' . '<br>';

//5、一天后(即24小时后)的时间戳
echo ' ----- 一天后(即24小时后)的时间戳 ----- ' . '<br>';
echo 'strtotime(\'+1 day\')' . '<br>';
echo strtotime('+1 day') . '<br>';
echo date('Y-m-d H:i:s', strtotime('+1 day')) . '<br>' . '<br>';

echo 'strtotime(\'+1 days\')' . '<br>';
echo strtotime('+1 days') . '<br>';
echo date('Y-m-d H:i:s', strtotime('+1 days')) . '<br>' . '<br>';

posted on 2023-07-14 11:23  WebLinuxStudy  阅读(17)  评论(0编辑  收藏  举报