
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How to get timestamp using MySQL?
You can get timestamp with the help of current_timestamp, now() and current_timestamp().
Case 1 − Using current_timestamp()
The query is as follows −
mysql> SELECT CURRENT_TIMESTAMP();
The following is the output displaying timestamp −
+---------------------+ | CURRENT_TIMESTAMP() | +---------------------+ | 2018-11-29 16:09:31 | +---------------------+ 1 row in set (0.00 sec)
Case 2 − Using now()
The query is as follows −
mysql> select now();
The following is the output −
+---------------------+ | now() | +---------------------+ | 2018-11-29 16:09:38 | +---------------------+ 1 row in set (0.00 sec)
You can get integer UNIX timestamp with the help of below query −
mysql> select unix_timestamp();
The following is the output −
+------------------+ | unix_timestamp() | +------------------+ | 1543488374 | +------------------+ 1 row in set (0.04 sec
- Related Articles
- How to get day name from timestamp in MySQL?
- How to convert from Unix timestamp to MySQL timestamp value?
- Get timestamp date range with MySQL Select?
- MySQL command to order timestamp values in ascending order without using TIMESTAMP()?
- Convert MySQL timestamp to UNIX Timestamp?
- Get only the date in timestamp in MySQL?
- How to get a timestamp in JavaScript?
- How to order by timestamp in MySQL?
- How to get the Unix timestamp in C#
- How to convert MySQL datetime to Unix timestamp?
- How to convert timestamp to datetime in MySQL?
- How to select date from timestamp in MySQL?
- How to Insert custom date into MySQL timestamp field?
- How to get yesterday records from timestamp in Android sqlite?
- How to get current timestamp and relative timestamps in PostgreSQL?

Advertisements