Join Kevin Skoglund for an in-depth discussion in this video Convert to user's time zone, part of Easy PHP Projects: Time Zone Conversion.
- [Voiceover] In the previous movie,…we've created a basic HTML page…that displays the current date and time.…Now, we want to make that date and time…be sensitive to the user's preferred time zone.…That's going to be a three-step process.…First, we need to retrieve…the stored time zone identifier string for that user.…That might be in a database, or in our case,…that's going to be in the session variable.…Second, we're going to create a DateTimeZone object…using that identifier string.…
And then third, we'll take that DateTimeZone object…and we'll use it to set the DateTime object…to the correct time zone.…Remember, we have to have an object to do that.…We can't just pass in a string to the DateTime object,…we have to instantiate a DateTimeZone object first.…Very important.…Let's see how we do this.…So the very first thing we need to do is…retrieve that value from the session.…And, the place that we're going to do that…is up here at the top,…and we need to first have session_start,…in order to have access to that session.…
- Understanding the history and purpose of time zones
- Setting a default time zone in PHP
- Using the PHP DateTime and DateTimeZone classes
- Working with daylight saving time transitions
- Allowing users to select their time zone
- Displaying times in the user's preferred time zone
- Calculating the current times of major cities
- Creating a complete time zone calculator
Skill Level Beginner
1. About Time Zones
2. Default Time Zone
3. Working with Time Zones in PHP
4. User Time Zone Selection
5. Respect the User's Time Zone
6. Current World Times
7. Time Zone Calculator
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.