典雅的检查,如果给定的日期是昨天

问题描述:

假设你有一个Unix时间戳,这将是一件容易的和/或优雅的方式来检查,如果该时间戳是一段时间昨天?

Assuming you have a Unix timestamp, what would be an easy and/or elegant way to check if that timestamp was some time yesterday?

我主要是找在Javascript,PHP或C#,但伪代码和语言无关的解决方案(如果有的话),欢迎为好。

I am mostly looking for solutions in Javascript, PHP or C#, but pseudo code and language agnostic solutions (if any) are welcome as well.

PHP解决方案

$isYesterday = date('Ymd', $timestamp) == date('Ymd', strtotime('yesterday'));