일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
- Sring Functions and Operators
- 전자정부 표준프레임워크
- 윈도우
- 전자정부표준프레임워크
- String Functions and Operators
- Date and Time Functions
- Oracle
- MySQL
- String Functions and Date Operators
- String Function and Operators
- SVN
- Tibero
- Date and Time Function
- 티베로
- 방화벽
- 오라클
- HTTP
- Data and Time Functions
- Today
- Total
웹이야기
MySQL UNIX_TIMESTAMP() 본문
MySQL 날짜함수, 시간함수
UNIX_TIMESTAMP()
-
UNIX_TIMESTAMP([date])
의 형태
If UNIX_TIMESTAMP() is called with no date argument, it returns a Unix timestamp representing seconds since '1970-01-01 00:00:00' UTC.
If UNIX_TIMESTAMP() is called with a date argument, it returns the value of the argument as seconds sincd '1970-01-01 00:00:00' UTC. The server interprets date as a value in the session time zone and converts it to an internal Unix timestamp value in UTC.
The date argument my be a DATE, DATETIME, or TIMESTAMP string, or a number in YYMMDD, YYMMDDhhmmss, YYYYMMDD, or YYYYMMDDhhmmss format. If the argument includes a time part, it may optionally include a fractional seconds part.
The return value is an integer if no argument is given or the argument does not include a fractional seconds part, of DECIMAL if an argument is given that includes a fractional seconds part.
When the date argument is a TIMESTAMP column, UNIX_TIMESTAMP() returns the internal timestamp value directly, with no implicit "string-Unix-timestamp " conversion.
The valid range of argument values is the same as for the TIMESTAMP data type: '1970-01-01 00:00:01.000000' UTC to '2038-01-19 03:14:07.999999' UTC. If you pass an out-of-range date to UNIX_TIMESTAMP(), it returns 0;
mysql> SELECT UNIX_TIMESTAMP();
+------------------+
| UNIX_TIMESTAMP() |
+------------------+
| 1586057681 |
+------------------+
1 row in set (0.00 sec)
mysql> SELECT UNIX_TIMESTAMP(NOW());
+-----------------------+
| UNIX_TIMESTAMP(NOW()) |
+-----------------------+
| 1586057690 |
+-----------------------+
1 row in set (0.00 sec)
mysql> SELECT UNIX_TIMESTAMP('2020-04-01 14;35;34');
+---------------------------------------+
| UNIX_TIMESTAMP('2020-04-01 14;35;34') |
+---------------------------------------+
| 1585719334 |
+---------------------------------------+
1 row in set (0.00 sec)
mysql> SELECT UNIX_TIMESTAMP('2020-04-01 14;35;34.987654');
+----------------------------------------------+
| UNIX_TIMESTAMP('2020-04-01 14;35;34.987654') |
+----------------------------------------------+
| 1585719334.987654 |
+----------------------------------------------+
1 row in set (0.00 sec)
mysql> SELECT UNIX_TIMESTAMP('2099-01-01 12:00:00');
+---------------------------------------+
| UNIX_TIMESTAMP('2099-01-01 12:00:00') |
+---------------------------------------+
| 0 |
+---------------------------------------+
1 row in set (0.00 sec)
'D > MySQL' 카테고리의 다른 글
MySQL UTC_TIME() (0) | 2020.04.05 |
---|---|
MySQL UTC_DATE() (0) | 2020.04.05 |
MySQL TO_SECONDS() (0) | 2020.04.05 |
MySQL TO_DAYS() (0) | 2020.04.05 |
MySQL TIME_TO_SEC() (0) | 2020.04.05 |