Join Kevin Skoglund for an in-depth discussion in this video More efficient sorting, part of Easy PHP Projects: Time Zone Conversion.
- [Voiceover] In this last movie, we saw…how to sort our list of cities by their timezone offset.…In this movie, I want us to look at how we can…do that a bit more efficiently.…One of the best practices to try and follow…in programming is don't repeat yourself.…If you find that you're repeating yourself,…then it's a clue that there may be some inefficiencies…and you may be able to improve your code…by rewriting things, refactoring, so that…you can remove that repetition.…We have two different loops here.…One that takes place before we sort…and one that takes place after…and I think it's unavoidable for us to have…to have two loops but what I object to…is the fact that we're repeating ourselves here.…
For me it's line 48 and 49, and it occurs again down here…in line 57 and 58, and both cases I'm instantiating…a new object and setting the timezone to that object.…Now I don't actually know how expensive this…process is and would it, might be…worth just keeping things simpler like this or not.…But as an exercise, I want us to go ahead and…
- 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?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
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.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.