Join Kevin Skoglund for an in-depth discussion in this video Store dates in a database, part of Easy PHP Projects: Time Zone Conversion.
- [Voiceover] In this movie, I want to take a moment…to discuss how you should go about…storing dates in a database.…Previously we talked about storing…the user's time zone preference in a database,…but here I'm talking about storing actual dates and times.…The reason why I want to mention it now…is because the process is very similar…to what you just did in the last challenge.…First, it's always best to put…all your dates in the database in the UTC time zone.…Convert those dates to the UTC…before you write them to the database,…and convert them back from UTC…when you're reading those values back.…
Why do it that way?…Because it allows for searching…and aggregating the raw data of the database.…The values can be used immediately…without needing to be aligned…in the right time zone first.…Imagine for a moment that I have a table of users,…and I've stored the sign up date for those users…in the database.…If I want to find everyone who signed up…between 9am and 11am Eastern Standard Time,…then I can convert 9am to 11am Eastern Standard Time…
- 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.