Why Dates and Times are HARD!

Опубликовано: 02 Апрель 2026
на канале: Metaphorically Speaking
1,464
83

Dates and times are hard (and not just in Laravel or PHP!), but they aren't broken.

Most of the time, they work fine, but when they don't - it can be super confusing. From off-by-one errors and almost borderline unexplainable results from calculations - it's easy to fear dates.

But don't.

Accept the fact that dates can be weird because dates are weird in the real world, too!

In this video, I explore a recent issue I encountered when quickly writing a script to get some data within a date range. The data returned was not what I expected - and off by quite a lot!

But, as I show within the video, there was a (relatively) logical explanation for this, and some simple fixes. And, at the end, I'll share some advice for working with dates.

You can read more about the date formats in PHP on the docs:
https://www.php.net/manual/en/datetim...

---

If you would like to support the creation of these videos, or would simply like the source code for this video - you can sign up for Patreon (here:   / acairns  ) where I share the code for each video.

---

0:00 Intro
0:22 Problem
2:22 Explanation
2:55 Solution
3:30 Advice
4:33 Outro

---

Credits:

Michael McIntyre / BBC

---

Website: https://acairns.co.uk
Twitter:   / andrewcairns  
Patreon:   / metaphoricallyspeaking  
Discord: https://acairns.co.uk/discord
Substack: https://acairns.substack.com

#laravel #php