Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed PHP Standards and Best Practices!
You have completed PHP Standards and Best Practices!
Preview
In the olden days, PHP developers converted everything to unix timestamps before comparing dates, but now using DateTime you can just compare the objects directly.
This video doesn't have any notes.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
Date comparisons are made very easy in
PHP.
0:00
Many older tutorials will suggest you have
to turn all dates into Unix time
0:01
stamps before you can compare the number
of seconds, but
0:04
date time objects can be compared
directly.
0:07
Try and steer clear of the old date, and
STR time functions.
0:10
And definitely avoid adding and
subtracting specific numbers of
0:13
seconds to change dates due to time zone
complications.
0:16
Let's take a look at time zones in the
next video.
0:20
Let's open the index.php file in our work
space now.
0:24
And have a look at another handy feature
of date time that is often under utilized.
0:26
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up