Join Kevin Skoglund for an in-depth discussion in this video Improve offset formatting, part of Easy PHP Projects: Time Zone Conversion.
- [Voiceover] In the last movie, we saw how to add…the offset from UTC to the time zones option list.…In this movie, we'll improve the formatting…of those offset values.…So what we've already done is,…we used the DateTime object to get the offset…and divided it by 3600, and then we displayed it to the user…and it looks something like this.…What we don't like is the fact that this says minus four…and this says one and two and so on.…It doesn't really give us a time.…It doesn't feel like it's a time.…In fact, here, it's not even really clear what this is.…
UTC/GMT one.…What does that mean?…That's not the way that we usually see these represented.…So we need to do some formatting here.…And there are a couple of ways that we could do that.…The first is that we could add…a new function called…function format_hours_minutes.…We'll pass in a float to that.…And then in there we could actually just do the formatting…that we need.…We can take that float apart.…We can use floor to find out what the integer portion is.…
That'll give us the hours.…
- 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.