Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

LinkedIn Learning

PHP Date and Time Essential Training

via LinkedIn Learning

Overview

Learn to use the intricate and sometimes underused capabilities of PHP's date and time functions to create, format, calculate, and compare dates and times.

Need to calculate the date of the third Thursday of each month or the Friday after next? PHP—and David Powers—have you covered. David shows how to use the intricate and sometimes underused capabilities of PHP's date and time functions, including the basic date/time formatting functions in PHP 4 and the more advanced functions introduced in PHP 5. For example, you can learn how to find and set time zones, perform date calculations that incorporate different time zones and daylight savings, and calculate the time of sunrises and sunsets. Start watching and learn how to incorporate these powerful functions into your programming arsenal.

Syllabus

Introduction
  • Welcome
  • What you should know before watching this course
  • Using the exercise files
1. Handling Dates and Times in PHP
  • What's involved in storing dates and time
  • How PHP handles dates and time
  • Setting the default time zone
2. Basic Date and Time Functions
  • Displaying the current date and time
  • Checking that a date is valid
  • Timing how long a script runs
  • Using time() to end a session after a period of inactivity
  • Getting a Unix time stamp for a specific date or time
  • Getting a time stamp from text
3. Using the DateTime class
  • Introducing the DateTime class
  • Creating a DateTime object
  • Displaying the value of a DateTime object
  • Extending DateTime to create a default format
  • Getting the time stamp from a DateTime object
  • Using a time stamp to set the date and time
  • Modifying the time stamp with a date string
  • Troubleshooting incorrect dates
  • Setting the date and time independently
  • Creating a DateTime object from a custom format
  • Comparing DateTime objects
  • Preserving the original date when modifying the time stamp
4. Working with Time Zones
  • Finding the correct time zone from an abbreviation
  • Finding time zones by country
  • Getting the time zone of a DateTime object
  • Creating a DateTime object for a different time zone
  • Changing a DateTime object's time zone
  • Finding the time difference between locations
  • Finding out when the clocks change
5. Using the DateInterval and DatePeriod classes
  • Introducing the DateInterval and DatePeriod classes
  • Creating a DateInterval
  • Adding and subtracting dates
  • Finding the difference between two dates or times
  • Formatting a DateInterval
  • Generating a sequence of dates at regular intervals
  • Finding the third Thursday in each month
6. Working with ISO Week Dates
  • Understanding ISO week dates
  • Creating a DateTime object for an ISO week date
  • Finding the ISO week date
7. Calculating Sunrise and Sunset
  • Finding when the sun rises and sets
  • Getting more information about sunrise and sunset
  • Calculating the number of daylight hours
8. Dates and Databases
  • What's different about how dates are stored?
  • Formatting a date to insert into MySQL/MariaDB
  • Using separate input fields for each date part
  • Using PHP to format a date retrieved from a database
  • Using the MySQL DATE_FORMAT() function
  • Using other MySQL date and time functions
Conclusion
  • Goodbye

Taught by

David Powers

Reviews

Start your review of PHP Date and Time Essential Training

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.