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
Dates and times in PHP used to be quite a mess in the PHP 4 days, but the DateTime class has brought much easier workflows.
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
time related functions in PHP besides the
date time class, but
0:00
this provides a nice object oriented
interface to most of the common uses.
0:03
So let’s start off by opening index dot
PHP.
0:07
On line three, we’re going to create a new
date time object and
0:09
store it in the date variable.
0:12
In this case,
0:14
we'll be creating a object by passing a
string into the class constructor.
0:15
This string will contain a date, which can
be in one of a bunch of different formats.
0:19
We'll look at some of these formats
shortly, but for
0:23
now, this example has an input format of
year, comma, August 23.
0:24
On line seven we're outputting a paragraph
of the text.
0:29
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