PHP – DateTime Object – Full PHP 8 Tutorial
27.3K views on YouTube
In this lesson, you will learn how to work with dates & times in Object-Oriented PHP using date classes such as DateTime, DateTimezone, DateInterval, DatePeriod, & DateTimeImmutable. You will learn how to add, subtract, compare & change dates as well as calculate differences. You will learn what to look out for and potential bugs when working with DateTime & DateInterval objects & how to solve such issues.
SOME OF THE WAYS YOU CAN SUPPORT THE CHANNEL
👍 Smash the like button
🤝 Subscribe to the channel & turn the notifications on
💬 Post comments, any feedback is greatly appreciated
⭐ Become a Patreon: https://www.patreon.com/programwithgio
THANK YOU!
LESSON 2.21
Course Outline – https://github.com/ggelashvili/learnphptherightway-outline
Course Playlist – https://www.youtube.com/playlist?list=PLr3d3QYzkw2xabQRUpcZ_IBk9W50M9pe-
RESOURCES
Lesson 1.25 Working with dates procedural way using date & time functions – https://youtu.be/Zf9MWSUKpVM
Lesson 2.16 Object Comparison & how objects are stored (zval container) – https://youtu.be/zCGmZb3z-r8
Carbon PHP Library – https://carbon.nesbot.com/docs/
DateTime docs – https://www.php.net/manual/en/book.datetime.php
Docs for strtotime function & differences between dashes, slashes & periods when parsing dates – https://www.php.net/manual/en/function.strtotime.php
Supported date & time formats – https://www.php.net/manual/en/datetime.formats.php
Date interval formats – https://www.php.net/manual/en/dateinterval.format.php
Date interval construct (duration formats) – https://www.php.net/manual/en/dateinterval.construct.php
Date period – https://www.php.net/manual/en/class.dateperiod.php
CHAPTERS
00:00 – Creating datetime objects
01:21 – Working with timezones & formatting dates – setTimezone(), getTimezone(), format()
03:43 – Change date & time on datetime objects – setDate(), setTime()
05:53 – Create datetime objects from specific formats – DateTime::createFromFormat()
10:28 – Compare dates
11:43 – Calculate difference between two dates & DateInterval class
16:03 – Add & subtract dates
17:26 – Problem with DateTime object when modifying dates & times & how to solve it
20:47 – Immutable datetime objects
22:21 – Iterating over dates in a period – DatePeriod class
24:34 – Intro to Carbon date library