【问题标题】:Timestamp in 5 days from today in at 0 o'clock从今天起 5 天的时间戳在 0 点
【发布时间】:2020-10-21 14:40:41
【问题描述】:

我正在寻找一种简单的方法来获取相对于今天但在特定时间的时间戳。

示例: 现在是 07-01-2020 上午 10:00。 结果:06.07.2020 0 点的时间戳

只是今天的价值观是可变的。 strtotime() 有很好的可能性吗?

【问题讨论】:

  • 您在寻找这样的东西吗? $dateplusfive = date('Y-m-d', strtotime('+5 days'));
  • 是的,但在特定时间。我找到了以下解决方案,也许不是最好的。

标签: php wordpress date timestamp strtotime


【解决方案1】:

我找到了一个解决方案,也许不是最好的。

$newdate = date('Y-m-d H:i:s', strtotime('+ 5 days 2 hours',strtotime('today midnight')));```

【讨论】:

  • 为什么还要额外的 2 小时?
  • 另外你为什么不看看 mktime();功能。这样可以更好地控制获取午夜时间戳。
猜你喜欢
  • 2015-04-14
  • 1970-01-01
  • 1970-01-01
  • 2011-06-14
  • 1970-01-01
  • 2014-10-18
  • 2012-10-19
  • 1970-01-01
  • 2017-01-13
相关资源
最近更新 更多