Search code examples
c#phpjavascriptlanguage-agnosticunix-timestamp

Elegantly check if a given date is yesterday


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

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


Solution

  • PHP:

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