Uploaded June 2021 | Updated November 2026, 3 hours ago
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: patreon.com/programwithgio
THANK YOU!
LESSON 2.21
Course Outline - github.com/ggelashvili/learnphptherightway-outline
Course Playlist - youtube.com/playlist?list=PLr3d3QYzkw2xabQRUpcZ_IBk9W50M9pe-
RESOURCES
Lesson 1.25 Working with dates procedural way using date & time functions - youtu.be/Zf9MWSUKpVM
Lesson 2.16 Object Comparison & how objects are stored (zval container) - youtu.be/zCGmZb3z-r8
Carbon PHP Library - carbon.nesbot.com/docs
DateTime docs - php.net/manual/en/book.datetime.php
Docs for strtotime function & differences between dashes, slashes & periods when parsing dates - php.net/manual/en/function.strtotime.php
Supported date & time formats - php.net/manual/en/datetime.formats.php
Date interval formats - php.net/manual/en/dateinterval.format.php
Date interval construct (duration formats) - php.net/manual/en/dateinterval.construct.php
Date period - 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
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: patreon.com/programwithgio
THANK YOU!
LESSON 2.21
Course Outline - github.com/ggelashvili/learnphptherightway-outline
Course Playlist - youtube.com/playlist?list=PLr3d3QYzkw2xabQRUpcZ_IBk9W50M9pe-
RESOURCES
Lesson 1.25 Working with dates procedural way using date & time functions - youtu.be/Zf9MWSUKpVM
Lesson 2.16 Object Comparison & how objects are stored (zval container) - youtu.be/zCGmZb3z-r8
Carbon PHP Library - carbon.nesbot.com/docs
DateTime docs - php.net/manual/en/book.datetime.php
Docs for strtotime function & differences between dashes, slashes & periods when parsing dates - php.net/manual/en/function.strtotime.php
Supported date & time formats - php.net/manual/en/datetime.formats.php
Date interval formats - php.net/manual/en/dateinterval.format.php
Date interval construct (duration formats) - php.net/manual/en/dateinterval.construct.php
Date period - 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










