Home > Backend Development > PHP Tutorial > How to use mysql time conversion function_PHP tutorial

How to use mysql time conversion function_PHP tutorial

WBOY
Release: 2016-07-21 14:57:41
Original
754 people have browsed it

Usage of mysql time conversion function 2007-10-31 15:03DAYOFWEEK(date)
Returns the week index of date (1=Sunday, 2=Monday, ...7=Saturday ). These index values ​​correspond to the ODBC standard.
mysql> select DAYOFWEEK(2007-10-31);
-> 4

WEEKDAY(date)
Returns the week index of date (0=Monday, 1=Tuesday, ...6=Sunday).
mysql> select WEEKDAY('2007-10-31 13:05:00');
-> 2
mysql> select WEEKDAY('2007-10-31');
- > 2

DAYOFMONTH(date)
Returns the day of the month of date, in the range of 1 to 31.
mysql> select DAYOFMONTH('2007-10-31');
-> 31

DAYOFYEAR(date)
Returns the number of days of the year in date, in the range of 1 to 366.
mysql> select DAYOFYEAR('2007-10-31');
-> 304


MONTH(date)
Returns the month of date, ranging from 1 to 12.
mysql> select MONTH('2007-10-31');
-> 10

DAYNAME(date)
Returns the day of the week name of date.
mysql> select DAYNAME("2007-10-31");
-> 'Wednesday'

MONTHNAME(date)
Returns the month name of date.
mysql> select MONTHNAME("2007-10-31");
-> 'October'

QUARTER(date)
Returns the quarter of the year for date, ranging from 1 to 4.
mysql> select QUARTER('2007-10-31');
-> 4

WEEK(date)

WEEK(date,first)
For places where Sunday is the first day of the week, there is a single parameter that returns the week number of date, in the range of 0 to 52. The 2-argument form of WEEK() allows you to specify whether the week starts on Sunday or Monday. If the second parameter is 0, the week starts on Sunday, if the second parameter is 1, it starts on Monday.
mysql> select WEEK('1998-02-20');
-> 7
mysql> select WEEK('1998-02-20',0);
-> 7
mysql> select WEEK('1998-02-20',1);
-> 8

YEAR(date)
Returns the year of date, ranging from 1000 to 9999.
mysql> select YEAR('98-02-03');
-> 1998

HOUR(time)
Returns the hour of time, ranging from 0 to 23.
mysql> select HOUR('10:05:03');
-> 10

MINUTE(time)
Returns the minute of time, ranging from 0 to 59.
mysql> select MINUTE('98-02-03 10:05:03');
-> 5

SECOND(time)
Returns the number of seconds of time, ranging from 0 to 59.
mysql> select SECOND('10:05:03');
-> 3

PERIOD_ADD(P,N)
Add N months to phase P (in format YYMM or YYYYMM). Returns the value in the format YYYYMM. Note that the phase parameter P is not a date value.​

  • Total 5 pages:
  • Previous page
  • 1
  • 2
  • 3
  • 4
  • 5
  • Next page

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/364003.htmlTechArticlemysql time conversion function usage 2007-10-31 15:03DAYOFWEEK(date) returns the week index of date ( 1=Sunday, 2=Monday, 7=Saturday). These index values ​​correspond to the ODBC standard. mys...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template