Day of week: Difference between revisions

From LemonWiki共筆
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
Numeric representation of the day of the week


{| class="wikitable sortable nowrap"
{| class="wikitable sortable nowrap"
Line 10: Line 11:
! Friday
! Friday
! Saturday
! Saturday
|-
! Weekday (ISO-8601 [http://php.net/manual/en/function.date.php PHP date] N character)
| 7
| 1
| 2
| 3
| 4
| 5
| 6
|-
|-
! Weekday ([https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_weekday MySQL])
! Weekday ([https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_weekday MySQL])
Line 19: Line 29:
| 4
| 4
| 5
| 5
|-
! Weekday ([https://support.office.com/zh-tw/article/WEEKDAY-%E5%87%BD%E6%95%B8-60e44483-2ed1-439f-8bd0-e404c190949a Excel])
| 1
| 2
| 3
| 4
| 5
| 6
| 7
|-
! Weekday ([http://php.net/manual/en/function.date.php PHP date] w character)
| 0
| 1
| 2
| 3
| 4
| 5
| 6
|-
|-
! Last week
! Last week
Line 50: Line 78:


further reading
further reading
* PHP [http://php.net/manual/en/function.date.php date] function
* PHP [http://php.net/manual/en/function.date.php date] function: w character (0 for Sunday through 6 for Saturday) or N character (1 for Monday through 7 for Sunday)


[[Category:PHP]]  
[[Category:PHP]]  

Revision as of 12:38, 21 August 2017

Numeric representation of the day of the week

Day Sunday Monday Tuesday Wednesday Thursday Friday Saturday
Weekday (ISO-8601 PHP date N character) 7 1 2 3 4 5 6
Weekday (MySQL) 6 0 1 2 3 4 5
Weekday (Excel) 1 2 3 4 5 6 7
Weekday (PHP date w character) 0 1 2 3 4 5 6
Last week SELECT CURDATE() + INTERVAL -8 - WEEKDAY(CURDATE()) DAY;
This week SELECT CURDATE() + INTERVAL -1 - WEEKDAY(CURDATE()) DAY; SELECT CURDATE() + INTERVAL 0 - WEEKDAY(CURDATE()) DAY; SELECT CURDATE() + INTERVAL 1 - WEEKDAY(CURDATE()) DAY; SELECT CURDATE() + INTERVAL 2 - WEEKDAY(CURDATE()) DAY; SELECT CURDATE() + INTERVAL 3 - WEEKDAY(CURDATE()) DAY; SELECT CURDATE() + INTERVAL 4 - WEEKDAY(CURDATE()) DAY; SELECT CURDATE() + INTERVAL 5 - WEEKDAY(CURDATE()) DAY;
Next week SELECT CURDATE() + INTERVAL 6 - WEEKDAY(CURDATE()) DAY;

further reading

  • PHP date function: w character (0 for Sunday through 6 for Saturday) or N character (1 for Monday through 7 for Sunday)