Join David Powers for an in-depth discussion in this video Using other MySQL date and time functions, part of PHP Date and Time Essential Training.
- [Voiceover] MySQL has a large range…of date and time functions…that can help perform useful tasks…without the need for complex sorting or filtering in PHP.…They're all listed here in the MySQL online documentation…with a brief description of what they do,…so let's just scroll down a little bit,…and this one here, DAYNAME, returns the name of the weekday,…and if you click the name of any of these functions,…it takes you directly to an example of how to use it,…so in the case of DAYNAME, you simply pass it the date…as the argument, and it returns the name of the weekday…using the same language as the MySQL server locale,…so for an English setup, it returns Monday,…Tuesday, Wednesday and so on.…
This example shows an actual date being passed…as the argument, but it can also be the name of a column…that stores a date or time stamp,…and then just down here is another one, DAYOFWEEK.…This also takes a date as an argument,…and it returns the weekday index for that date.…Sunday is 1, Monday is 2, and so on.…So we can use these two functions to select records…
Author
Updated
7/8/2016Released
3/3/2015- How PHP handles dates and time
- Setting the default time zone
- Displaying current date and time
- Getting a timestamp from text
- Using the DateTime class
- Getting and modifying a timestamp from DateTime
- Comparing DateTime objects
- Working with time zones
- Using DateInterval and DatePeriod
- Finding ISO week dates
- Calculating sunrise and sunset
Skill Level Intermediate
Duration
Views
Q: How does calculating sunrise and sunset (as shown in chapter 7) work for locations north of the Arctic Circle?
A: In polar regions, date_sun_info() reports the value for sunrise and sunset as 1 on days when the sun never sets. The values are empty for days when the sun never rises.
Related Courses
-
PHP: Accessing Databases with PDO and MySQLi
with David Powers3h 47m Intermediate -
Code Clinic: PHP
with David Powers4h 44m Intermediate -
PHP: Creating Secure Websites
with Kevin Skoglund4h 15m Intermediate
-
Introduction
-
Welcome1m 2s
-
Using the exercise files3m 10s
-
-
1. Handling Dates and Times in PHP
-
2. Basic Date and Time Functions
-
3. Using the DateTime class
-
Creating a DateTime object4m 27s
-
4. Working with Time Zones
-
5. Using the DateInterval and DatePeriod classes
-
Creating a DateInterval4m 12s
-
Adding and subtracting dates4m 44s
-
Formatting a DateInterval5m 32s
-
6. Working with ISO Week Dates
-
Understanding ISO week dates2m 57s
-
Finding the ISO week date4m 24s
-
-
7. Calculating Sunrise and Sunset
-
8. Dates and Databases
-
Conclusion
-
Goodbye1m 56s
-
- 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.
CancelTake 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.
Share this video
Embed this video
Video: Using other MySQL date and time functions