在PHP中获取今天和昨天的时间戳 [英] Get timestamp of today and yesterday in php

查看:58
本文介绍了在PHP中获取今天和昨天的时间戳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过使用php中的strtotime()函数获取今天,昨天和前天的12点时间戳?

How can I get the timestamp of 12 o'clock of today, yesterday and the day before yesterday by using strtotime() function in php?

12点是一个变量,将由用户更改.

12 o'clock is a variable and would be changed by user.

推荐答案

$hour = 12;

$today              = strtotime($hour . ':00:00');
$yesterday          = strtotime('-1 day', $today);
$dayBeforeYesterday = strtotime('-1 day', $yesterday);

这篇关于在PHP中获取今天和昨天的时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆